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
Adds a tag to every operation started by the current thread (and threads it creates later), so they can be interrupted together with interruptTag. A tag must be non-empty and must not contain ,.
Adds a tag to every operation started by the current thread (and threads it creates later), so they can be interrupted together with interruptTag. A tag must be non-empty and must not contain ,.
Attributes
Removes all of the current thread's operation tags.
Removes all of the current thread's operation tags.
Attributes
Clones this session on the server (Spark 4.1+): the new session starts with a copy of this session's SQL configurations, temporary views, registered functions, and catalog state, and is independent afterwards.
Clones this session on the server (Spark 4.1+): the new session starts with a copy of this session's SQL configurations, temporary views, registered functions, and catalog state, and is independent afterwards.
Attributes
Like cloneSession, with the given session id (a UUID) for the clone.
Attributes
- Definition Classes
-
AutoCloseable
Returns an empty Dataset of type T.
Returns an empty Dataset of type T.
Attributes
Runs command in an external execution engine (runner, e.g. a JDBC data source) rather than Spark, returning the command's output, if any, as a DataFrame.
Runs command in an external execution engine (runner, e.g. a JDBC data source) rather than Spark, returning the command's output, if any, as a DataFrame.
Attributes
The tags the current thread attaches to the operations it starts.
The tags the current thread attaches to the operations it starts.
Attributes
Interrupts all operations of this session; returns the ids of interrupted operations.
Interrupts all operations of this session; returns the ids of interrupted operations.
Attributes
Interrupts the operation with the given id; returns the ids of interrupted operations.
Interrupts the operation with the given id; returns the ids of interrupted operations.
Attributes
Interrupts the operations with the given tag; returns the ids of interrupted operations.
Interrupts the operations with the given tag; returns the ids of interrupted operations.
Attributes
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: a fresh server-side session with its own configuration and temporary views.
Starts a new independent session against the same endpoint: a fresh server-side session with its own configuration and temporary views.
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
Creates a Dataset with a single id column of [0, end).
Creates a Dataset with a single id column of [0, end).
Attributes
Creates a Dataset with a single id column of [start, end).
Creates a Dataset with a single id column of [start, end).
Attributes
Creates a Dataset with a single id column of [start, end) stepping by step.
Creates a Dataset with a single id column of [start, end) stepping by step.
Attributes
Creates a Dataset with a single id column of [start, end) in numPartitions.
Creates a Dataset with a single id column of [start, end) in numPartitions.
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 statement, returning its result as a DataFrame. Like Apache Spark, the statement is sent to the server right away: commands (DDL / DML such as CREATE TABLE or INSERT) run immediately, while queries stay lazy until an action.
Executes a SQL statement, returning its result as a DataFrame. Like Apache Spark, the statement is sent to the server right away: commands (DDL / DML such as CREATE TABLE or INSERT) run immediately, while queries stay lazy until an action.
Attributes
Executes a SQL statement with positional parameters bound into the query.
Executes a SQL statement with positional parameters bound into the query.
Attributes
Executes a SQL statement with named parameters bound into the query.
Executes a SQL statement with named parameters bound into the query.
Attributes
(Java-specific) Executes a SQL statement with named parameters bound into the query.
(Java-specific) Executes a SQL statement 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
Runs f, printing the time it took to the console, and returns its result.
Runs f, printing the time it took to the console, and returns its result.
Attributes
Returns the table-valued functions, e.g. spark.tvf.explode(...).
Returns the table-valued functions, e.g. spark.tvf.explode(...).
Attributes
The version of Spark on which the connected server is running.
The version of Spark on which the connected server is running.
Attributes
Runs block with this session as the active session, restoring the previous one after.
Runs block with this session as the active session, restoring the previous one after.
Attributes
Concrete fields
Returns the org.apache.spark.sql.catalog.Catalog interface for this session.
Runtime configuration for Spark.
Runtime configuration for Spark.
Attributes
Returns a org.apache.spark.sql.streaming.StreamingQueryManager for this session.