Jump to content

Spark Connect

From Open Lakehouse Wiki
Spark Connect
Developer Apache Software Foundation (Apache Spark project)
Initial release Spark 3.4.0 (2023)
Latest release Spark 4.3.0
(2026-10-30)
Written in Scala, Python
Type Client-server protocol for Apache Spark
License Apache License 2.0
Website Spark Connect overview
Repository github.com/apache/spark (sql/connect)
Related Apache Spark, Spark Declarative Pipelines
Last verified 22 November 2026 against the Spark 4.3.0 Spark Connect documentation and source at tag v4.3.0, Spark release notes 3.4.0, 3.5.0 and 4.0.0, and PyPI.

Spark Connect is a client-server interface for Apache Spark in which a thin client library sends DataFrame operations to a remote Spark server as unresolved logical plans and receives the results over the network.[1] Spark Connect separates the application process from the Spark driver, so an application can run in an IDE, a notebook or a service without sharing a process or dependencies with the cluster. It was introduced in Spark 3.4.[1]

How it works

The Spark Connect client translates DataFrame operations into unresolved logical query plans, encodes them with Protocol Buffers and sends them to the server with gRPC.[1]

The Spark Connect endpoint on the server translates the received plans into Spark's logical plan operators, much as Spark parses a SQL query, and then runs them through the normal Spark optimizer and execution engine. Results return to the client over gRPC as Apache Arrow-encoded row batches.[1]

By default, a Spark Connect server listens on port 15002. The port is set by the static configuration spark.connect.grpc.binding.port, which has existed since Spark 3.4.0.[1][2] Clients address the server with a connection string that starts with sc://, for example sc://localhost:15002, given either in code or in the SPARK_REMOTE environment variable.[1]

Differences from classic Spark

Spark Connect changes what an application can reach, because the client runs outside the driver process:[1]

  • The client cannot access the driver JVM. In PySpark, the client does not use Py4J, so private fields such as df._jdf are not available.
  • The protocol describes work as logical plans, so it does not support every Spark execution API. Most importantly, RDDs are not supported.
  • Each client gets its own session. The client cannot change cluster-wide settings, and it has no access to the static Spark configuration or to the SparkContext.

The Spark documentation names stability, upgradability and debuggability as operational reasons for this split: an application that uses too much memory affects only its own process, the server can be upgraded independently of client applications, and applications can be debugged in a local IDE.[1]

Using Spark Connect

A server is started from a Spark distribution with the sbin/start-connect-server.sh script. A PySpark application then connects by passing a remote address when it builds the session:[1]

from pyspark.sql import SparkSession

spark = SparkSession.builder.remote("sc://localhost:15002").getOrCreate()
spark.range(10).filter("id % 2 = 0").show()

The shells accept the same address with --remote, for example ./bin/pyspark --remote "sc://localhost".[1] Scala applications use the spark-connect-client-jvm artifact and the same remote builder method. Scala code that contains user-defined functions must upload its class files and JAR dependencies to the server, for example with SparkSession#addArtifact.[1]

For Python, the pyspark-client package on PyPI contains only the Spark Connect client, without the JVM parts of PySpark.[1] Its latest version on 22 November 2026 is 4.3.0.[3]

Since Spark 4.0, the spark.api.mode configuration (values classic or connect, default classic) lets an existing classic application run through Spark Connect without code changes, by starting a local Spark Connect server for it.[4][5]

Clients

Client Where it lives Notes
Python (PySpark) apache/spark First released in Spark 3.4.0[6]
Scala apache/spark First released in Spark 3.5.0[7]
Go apache/spark-connect-go Announced with Spark 3.5.0[7]
Swift apache/spark-connect-swift Announced with Spark 4.0.0[8]
Rust apache/spark-connect-rust [9]

History

Spark Connect was proposed in the Spark Project Improvement Proposal (SPIP) tracked as SPARK-39375, filed in June 2022.[10] Spark 3.4.0 shipped the Python client.[6] Spark 3.5.0 added the Scala client, Structured Streaming support in Python and Scala, and pandas API on Spark support for the Python client.[7] Spark 4.0.0 added the pyspark-client package, an extra release tarball with Spark Connect enabled by default, the spark.api.mode setting and machine learning on Spark Connect.[8] Spark 4.3.0 added REST endpoints for inspecting sessions and operations, operation IDs for request attribution, and a more complete JDBC driver.[11]

Use in an open lakehouse

In an open lakehouse, Spark Connect lets light clients such as notebooks, services and AI agents run queries on a shared Spark cluster that holds the catalog and table format configuration. Spark Declarative Pipelines depends on it: in Spark 4.3 the spark-pipelines launcher requires spark.api.mode to be connect and rejects any other value.[12]

See also

References

  1. ↑ 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 Spark Connect Overview (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  2. ↑ Connect.scala (tag v4.3.0). Apache Spark on GitHub.Retrieved 2026-11-22.
  3. ↑ pyspark-client. Python Package Index.Retrieved 2026-11-22.
  4. ↑ Application Development with Spark Connect (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  5. ↑ Spark Configuration (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  6. ↑ 6.0 6.1 Spark Release 3.4.0. Apache Software Foundation.Retrieved 2026-11-22.
  7. ↑ 7.0 7.1 7.2 Spark Release 3.5.0. Apache Software Foundation.Retrieved 2026-11-22.
  8. ↑ 8.0 8.1 Spark Release 4.0.0. Apache Software Foundation.Retrieved 2026-11-22.
  9. ↑ apache/spark-connect-rust. GitHub.Retrieved 2026-11-22.
  10. ↑ SPARK-39375: SPIP: Spark Connect - A client and server interface for Apache Spark. Apache Software Foundation JIRA.Retrieved 2026-11-22.
  11. ↑ Spark Release 4.3.0. Apache Software Foundation.Retrieved 2026-11-22.
  12. ↑ SparkPipelines.scala (tag v4.3.0). Apache Spark on GitHub.Retrieved 2026-11-22.