Courseiva
Using Spark Connect →easyMultiple Choice

Databricks-Spark-Assoc Using Spark Connect Practice Question

A developer is writing a Spark Connect application and wants to create a SparkSession that connects to a remote Databricks cluster. The developer has the cluster's connection string and an access token. Which method should be used to build the session?

⚠ Common exam trap

Many exam-takers confuse the Spark Connect configuration property spark.remote with traditional Spark master settings, or using the wrong URL scheme.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

SparkSession.builder.config("spark.remote", "sc://<host>:<port>").getOrCreate()

To create a Spark Connect session, the developer must configure the spark.remote property with the Spark Connect server URL, which uses the sc:// scheme. The builder pattern with getOrCreate() is then used to instantiate the session. Other methods like master() or incorrect configuration keys will not establish a Spark Connect connection and may result in a local session or an error.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    SparkSession.builder.master("spark://<host>:<port>").getOrCreate()

    Why it's wrong here

    The master() method is used in traditional Spark to specify a cluster manager URL, such as spark://, yarn, or mesos. It is not used for Spark Connect. Spark Connect uses a different protocol and configuration (spark.remote). Using master() would attempt to create a local or cluster session, not a Spark Connect session.

  • ✗

    SparkSession.builder.appName("RemoteApp").config("spark.connect.host", "<host>").getOrCreate()

    Why it's wrong here

    There is no spark.connect.host configuration property in Spark Connect. The correct property is spark.remote. While appName is valid, it does not establish a remote connection. This option misnames the configuration key, leading to a local session instead of a remote one.

  • ✗

    SparkSession.builder.config("spark.remote", "spark://<host>:<port>").getOrCreate()

    Why it's wrong here

    The spark.remote configuration expects a URL with the sc:// scheme for Spark Connect, not spark://. The spark:// scheme is used for traditional Spark master URLs. Using the wrong scheme will cause the client to fail to connect to the Spark Connect server.

  • ✓

    SparkSession.builder.config("spark.remote", "sc://<host>:<port>").getOrCreate()

    Why this is correct

    In Spark Connect, the connection to a remote server is configured using the spark.remote configuration property, which specifies the URL of the Spark Connect server (e.g., sc://host:port). The builder pattern with getOrCreate() is the standard way to create a session. This method correctly sets the remote endpoint and initializes the session.

About these practice questions

One of 295 original Databricks-Spark-Assoc practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-Spark-Assoc practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-Spark-Assoc exam.