CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice question 7 of 25
A developer wants to test Spark Connect with an existing Spark application. What are the two alternative ways the developer can start a local Spark Connect server without changing their existing application code? (Choose 2 answers)
Full set: 135 questionsTo connect an existing Spark application to a Spark Connect server without code modification, the connection must be configured externally. The two primary methods are using a command-line flag when launching the application (like the PySpark shell) or setting an environment variable. The --remote "sc://localhost" flag instructs the PySpark shell to operate in Connect mode and connect to the specified server. Similarly, setting the SPARKREMOTE="sc://localhost" environment variable before launching any Spark application (including a shell or a submitted job) will configure the default SparkSession to connect to the specified remote server, overriding the default behavior of creating a local Spark session.
A. The https:// protocol is incorrect for Spark Connect; the correct protocol is sc://.
D. This option requires modifying the application's source code by adding .remote() to the SparkSession.builder call, which the question explicitly prohibits.
E. spark.connect.grpc.binding.port is a server-side configuration property that specifies the port the Spark Connect server listens on, not how a client connects to it.
1. Apache Spark 3.5.1 Documentation
Spark Connect Overview
"Start Spark Connect server and client": This section explicitly demonstrates the two valid methods.
For the command-line option: "To use Spark Connect with the PySpark shell
run the following command in the Spark root directory: ./bin/pyspark --remote sc://localhost". This validates option B.
For the environment variable: "Alternatively
you can set the SPARKREMOTE environment variable
for example
export SPARKREMOTE="sc://localhost"". This validates option C.
The documentation also shows the code-based method
.remote("sc://localhost")
confirming why option D is a valid method in general but incorrect for this specific question's constraint.
Question breakdown
Key idea: A Spark Connect client can be pointed at a server from outside the code, either with the --remote launch option or with the SPARK_REMOTE environment variable, using the sc:// scheme.
How to reach the answer
- The constraint is 'without changing their existing application code', which rules out any edit to the builder.
- Spark Connect URIs use the sc:// scheme, not https://.
- The pyspark --remote "sc://localhost" flag sets Connect mode at launch.
- Exporting SPARK_REMOTE="sc://localhost" makes the default SparkSession connect remotely without any code change.
Each option
Common trap: Option D is a valid way to use Spark Connect, so it is tempting, but it breaks the explicit no-code-change constraint.
In practice: Teams often move existing PySpark scripts to Spark Connect by setting SPARK_REMOTE in the environment or CI config, so the same code runs locally or against a remote server.
Remember: For Spark Connect without code changes, use --remote sc://... or SPARK_REMOTE=sc://...
Drafted with AI assistance and checked against the answer key.
Keep practicing
Take the free CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice questions
- Question 1You have: DataFrame A: 128 GB of transactions DataFrame B: 1 GB user lookup table Which s…
- Question 2A Spark DataFrame df is cached using the MEMORY_AND_DISK storage level, but the DataFrame…
- Question 344 of 55. A data engineer is working on a real-time analytics pipeline using Spark Struct…
- Question 8A data engineer is running a Spark job to process a dataset of 1 TB stored in distributed…
- Question 10A data engineer is building a Structured Streaming pipeline and wants the pipeline to rec…
- Question 11Given a DataFrame df that has 10 partitions, after running the code: result = df.coalesce…
