The entry point to programming Spark with the DataFrame API over Spark Connect.
val spark = SparkSession.builder
.remote("sc://localhost:15002")
.appName("my-app")
.getOrCreate()
spark.range(10).filter(col("id") % 2 === 0).show()
spark.stop()
A session owns the SparkConnectClient, a monotonic plan-id allocator (so every relation is uniquely identifiable to the server), an Arrow allocator for decoding results, and the RuntimeConfig facade.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait AutoCloseableclass Objecttrait Matchableclass Any
Members list
Type members
Classlikes
Implicit conversions ($"col", Seq(...).toDF(...)); use import spark.implicits.*.
Implicit conversions ($"col", Seq(...).toDF(...)); use import spark.implicits.*.
Attributes
- Supertypes
- Self type
-
implicits.type
Value members
Concrete methods
Attributes
- Definition Classes
-
AutoCloseable
Creates a DataFrame from an arbitrary RelType, tagging it with a unique plan id.
Creates a DataFrame from an arbitrary RelType, tagging it with a unique plan id.
This is the primary extension point for Spark Connect plugins: build any relation the server understands -- including a custom extension relation -- and turn it into a DataFrame. For the common case of a packed plugin message, prefer the extension overload.
Attributes
Creates a DataFrame backed by an extension relation carrying an already packed protobuf message. This is the Scala counterpart of the PySpark client's
Creates a DataFrame backed by an extension relation carrying an already packed protobuf message. This is the Scala counterpart of the PySpark client's
plan.extension.Pack(message); DataFrame(plan, session)
and targets server-side org.apache.spark.sql.connect.plugin.RelationPlugin implementations.
import com.google.protobuf.any.Any as ProtoAny
// `myPluginMessage` is a ScalaPB message generated from the plugin's own .proto.
// Existing DataFrames can be embedded via their `relation` (see Dataset.relation):
// val payload = MyPlugin(input = Some(existingDf.relation))
val payload: ProtoAny = ProtoAny.pack(myPluginMessage)
val df = spark.newDataFrame(payload)
Attributes
Wraps a RelType into a fresh proto.Relation tagged with a unique plan id.
Wraps a RelType into a fresh proto.Relation tagged with a unique plan id.
This is a low-level building block intended for Spark Connect plugin authors who need to construct custom relations (for example, a relation handled by a server-side org.apache.spark.sql.connect.plugin.RelationPlugin). It is a stable extension point but not part of the day-to-day DataFrame API; ordinary code should use range, sql, createDataFrame, and friends instead.
Attributes
Starts a new independent session against the same endpoint (fresh server-side session).
Starts a new independent session against the same endpoint (fresh server-side session).
Attributes
Creates a new Spark Declarative Pipeline (a dataflow graph) in this session. Available on Spark 4.1 and later servers.
Creates a new Spark Declarative Pipeline (a dataflow graph) in this session. Available on Spark 4.1 and later servers.
Attributes
Returns a DataFrameReader that can be used to read non-streaming data as a DataFrame.
Returns a org.apache.spark.sql.streaming.DataStreamReader for reading streaming data.
The client session id (a UUID).
The client session id (a UUID).
Attributes
Make this the active session for the current thread.
Make this the active session for the current thread.
Attributes
Executes a SQL query with positional parameters bound into the query.
Executes a SQL query with positional parameters bound into the query.
Attributes
Executes a SQL query with named parameters bound into the query.
Executes a SQL query with named parameters bound into the query.
Attributes
Releases the server-side session resources and closes the channel.
Releases the server-side session resources and closes the channel.
Attributes
Returns a org.apache.spark.sql.streaming.StreamingQueryManager for this session.
The version of Spark on which the connected server is running.
The version of Spark on which the connected server is running.
Attributes
Concrete fields
Returns the org.apache.spark.sql.catalog.Catalog interface for this session.
Runtime configuration for Spark.
Runtime configuration for Spark.