| name | spark-connect |
| description | Knowledge base for Spark Connect (Apache Spark 3.4โ3.5). Use when preparing for Sec 6 of the Databricks Certified Associate Developer for Apache Spark exam, configuring a Spark Connect client/server, or migrating PySpark code to the decoupled client-server architecture. Sources: spark.apache.org 3.5.7 docs + Databricks engineering blog. |
| allowed-tools | ["Read","Grep"] |
| argument-hint | ["topic","connection method","or chapter number"] |
Spark Connect โ Exam-Prep Knowledge Base
Source Spark version: 3.5.7 (latest 3.5.x docs) + 3.4 launch context | Chapters: 5 | Generated: 2026-05-24
Scope rule: Anything from Spark 3.4 โค version โค 3.5.x is in scope for the Databricks Certified Associate Developer for Apache Spark exam (Sec 6). Anything from Spark 4.x is flagged โ ๏ธ as out of exam scope. The skill is conservative โ when 4.x docs were used, content is marked accordingly.
How to Use This Skill
- Without arguments โ loads the Core Frameworks below (Spark Connect at exam depth).
- By topic โ ask about
gRPC, unresolved logical plan, sc:// URL, SPARK_REMOTE, start-connect-server.sh, etc. โ I find and read the relevant chapter.
- By chapter โ
ch01, ch02, ch03, ch04, ch05.
Core Frameworks & Mental Models
Spark Connect in one paragraph
Spark Connect = decoupled client-server architecture for Apache Spark, introduced in Spark 3.4 and matured for Scala in 3.5. The client (any language) builds a DataFrame query, serializes it as an unresolved logical plan in protocol buffers, ships it over gRPC to a Spark Connect server embedded in the Spark driver. The server resolves the plan against its Catalog, runs Catalyst + Tungsten as normal, and streams results back as Apache Arrow row batches. Result: thin clients, isolated client failures, independent upgrades.
Why it exists (4 pain points it solves)
- Stability โ a misbehaving user app can't crash the shared driver
- Upgradability โ driver upgrades independently of clients (stable protobuf protocol)
- Debuggability โ client is a normal local process you can attach a debugger to
- Language flexibility โ protocol is language-agnostic; multiple language clients possible
The wire protocol (memorize for the exam)
- Unresolved logical plans as the language-agnostic protocol
- Encoded with Protocol Buffers
- Transported over gRPC (HTTP/2)
- Results return as Apache Arrow row batches
Connection URL format
sc://<host>[:<port>][/;token=<token>]
- Scheme:
sc:// (Spark Connect)
- Default port: 15002
- Optional
;token=... parameter (opaque, forwarded to any HTTP/2 auth proxy in front)
3 ways to connect a client (all 3 in scope)
| # | Method | When to use |
|---|
| 1 | SPARK_REMOTE env var | Zero-code-change reuse of existing PySpark scripts |
| 2 | --remote CLI flag | Ad-hoc interactive shells |
| 3 | SparkSession.builder.remote("sc://...") | Standalone apps |
from pyspark.sql import SparkSession
spark = (SparkSession.builder
.remote("sc://localhost:15002")
.appName("MyApp")
.getOrCreate())
Server start (memorize the exact command shape)
./sbin/start-connect-server.sh \
--packages org.apache.spark:spark-connect_2.12:3.5.7
- Lives in
$SPARK_HOME/sbin/
--packages coordinate must match the Spark distribution version
- Default port 15002
- Stop:
./sbin/stop-connect-server.sh
Client install (Python)
pip install "pyspark[connect]==3.5.7"
Pulls grpcio>=1.48,<1.57, grpcio-status, googleapis-common-protos==1.56.4, pyarrow>=4.0.0,<13.0.0, pandas>=1.0.5. Requires Python 3.8+ and Java 8/11/17.
Client install (Scala sbt)
libraryDependencies += "org.apache.spark" %% "spark-sql-api" % "3.5.7"
libraryDependencies += "org.apache.spark" %% "spark-connect-client-jvm" % "3.5.7"
API support at a glance (Spark 3.5)
| Surface | PySpark | Scala |
|---|
| DataFrame / Functions / Column | โ
(3.4) | โ
(3.5) |
| Dataset (typed) | n/a | โ
(3.5) |
| Catalog | โ
| โ
(3.5) |
| KeyValueGroupedDataset | n/a | โ
(3.5) |
| Streaming (DataStreamReader/Writer/Query/Listener) | partial | โ
majority (3.5) |
| UDFs | โ
| โ
in shell; standalone needs ClassFinder |
| RDD | โ | โ |
| SparkContext | โ | โ |
PySpark API reference labels supported APIs with "Supports Spark Connect" โ always your authoritative check.
Migration cost from classic PySpark
Only the SparkSession creation line changes. Everything DataFrame-based stays identical. Code using RDD or SparkContext will not work over Connect.
Auth
- No built-in auth. Always front the server with an HTTP/2 proxy (TLS termination + token validation).
- Optional
;token= URL parameter is only metadata โ Spark Connect itself doesn't validate it.
Session class introspection (Python)
- Classic:
pyspark.sql.session.SparkSession
- Connect:
pyspark.sql.connect.session.SparkSession
Exam Sec 6 โ both objectives
- "Describe the features of Spark Connect" โ decoupled client/server + protocol stack (unresolved plans / protobuf / gRPC / Arrow) + the 4 benefits + supported APIs.
- "Describe the different deployment mode types (Client, Cluster, Local)" โ this is the classic Spark deployment-modes question (Local / Standalone / YARN client / YARN cluster / Kubernetes), covered in the
apache-spark skill, Ch 1. Spark Connect is orthogonal to deployment modes: the Connect server itself runs in any deployment mode; from the client's perspective you just point sc://... at it.
โ Post-3.5 features โ DO NOT memorize for the 3.5 exam
The book + 4.x docs surface these; treat as informational only:
spark.api.mode=connect (Spark 4.0+) โ config that routes classic spark-submit through Connect.
spark.remote=local[*] (Spark 4.0+) โ local-cluster shortcut for testing.
- Go / Rust / Swift official clients (Spark 4.0+) โ live in
apache/spark-connect-go, etc.
- Spark Connect as default execution mode (Spark 4.0+).
If a question mentions any of these, it's testing Spark 4.x, not 3.5. The current Databricks Associate exam (Oct 2025 guide) does not version-stamp on 3.5 explicitly but the syllabus aligns with 3.4โ3.5 features.
Chapter Index
| # | Title | Focus |
|---|
| ch01 | Features & Benefits | The "what" and "why"; 4 benefits; in-scope vs out-of-scope features |
| ch02 | Architecture & Wire Protocol | gRPC, protobuf, Arrow, unresolved logical plans โ 6-step request lifecycle |
| ch03 | Server Setup & Client Install | start-connect-server.sh, pip install pyspark[connect], sbt deps |
| ch04 | Client Connection (3 methods) | SPARK_REMOTE, --remote, SparkSession.builder.remote(...), sc:// URL |
| ch05 | API Support Matrix | What works (DataFrame), what doesn't (RDD, SparkContext); PySpark vs Scala |
Topic Index
- Apache Arrow โ ch02
- API support (what works/what doesn't) โ ch05
builder.remote() โ ch04
- Catalog (Scala) โ ch05
- ClassFinder /
registerClassFinder โ ch04, ch05
- Connection URL (
sc://) โ ch04
- Decoupled architecture โ ch01, ch02
- Default port (15002) โ ch03, ch04
- Dependencies (Python client) โ ch03
- gRPC โ ch02
- Migration from classic PySpark โ ch04, ch05
- Monolithic driver (legacy) โ ch01
- PySpark API support โ ch05
pip install pyspark[connect] โ ch03
- Protocol Buffers โ ch02
- RDD/SparkContext (not supported) โ ch05
- Scala API support โ ch05
- Session class (Python introspection) โ ch04
SPARK_REMOTE env var โ ch04
sc:// URL scheme โ ch04
- Spark Connect REPL (Scala) โ ch03, ch04
spark-connect_2.12 โ ch03
spark-connect-client-jvm โ ch03
spark-sql-api โ ch03
start-connect-server.sh โ ch03
- Streaming over Connect (Scala) โ ch05
- Token (
;token=... in URL) โ ch02, ch04
- UDFs over Connect โ ch04, ch05
- Unresolved logical plan โ ch02
Supporting Files
- glossary.md โ alphabetical terms with chapter pointers + post-3.5 entries clearly flagged
- patterns.md โ concrete techniques (start server, migrate script, auth via proxy, Scala UDF artifact upload)
- cheatsheet.md โ single-page exam reference: URL format, 3 connection methods, API matrix, post-3.5 traps
Sources used to build this skill
Spark 3.5 official (primary):
Databricks engineering blog (context):
Spark 4.1 docs (used ONLY for client-setup code patterns; everything 4.x-specific is flagged โ ๏ธ):
To regenerate local snapshots: curl -sSL <url> -o source.html (or use WebFetch with extraction prompts) for each URL above.
Scope & Limits
This skill is calibrated for the Databricks Certified Associate Developer for Apache Spark exam, Sec 6 (Spark Connect), anchored to Spark 3.4โ3.5. For Spark 4.x features (multi-language clients, spark.api.mode=connect, etc.), see the latest Apache Spark docs โ but don't expect them on the current exam form.