dongjoon-hyun opened a new pull request, #485:
URL: https://github.com/apache/spark-connect-swift/pull/485
### What changes were proposed in this pull request?
This PR aims to support `cloneSession` API in `SparkSession` by using the
`CloneSession` RPC.
```swift
// Clone with a server-generated session ID
let cloned = try await spark.cloneSession()
// Clone with a custom session ID (must be a valid UUID)
let cloned = try await
spark.cloneSession("00112233-4455-6677-8899-aabbccddeeff")
```
- `SparkSession.cloneSession(_ newSessionID: String? = nil)` follows the
PySpark API shape (`cloneSession(new_session_id=None)`) and covers both Scala
overloads (`cloneSession()` / `cloneSession(sessionId:)`) via the optional
parameter.
- `SparkConnectClient.cloneSession` issues the `CloneSession` RPC and
validates that the returned session ID matches the requested one when provided,
like the Scala and Python clients.
- The existing `newSession()` semantics are unchanged, consistent with the
Scala client where `newSession()` (fresh empty session) and `cloneSession()`
(server-side state clone) are distinct APIs.
### Why are the changes needed?
The `CloneSession` RPC was added via
[SPARK-53455](https://github.com/apache/spark/commit/264ca4dc320c9de52ce53fdbdca8146ea9d1a5b6)
and is available since [Apache Spark 4.1.0
(2025-12-11)](https://github.com/apache/spark/releases/tag/v4.1.0). This allows
users to create a new independent session that inherits the original session's
server-side state (SQL configurations, temporary views, registered functions,
catalog state), which `newSession()` cannot provide.
### Does this PR introduce _any_ user-facing change?
Yes, this adds a new API, `SparkSession.cloneSession`. For old servers
without `CloneSession` RPC support (Apache Spark 4.0.x), the server error is
propagated like the Scala and Python clients.
### How was this patch tested?
Pass the CIs with the newly added integration tests, `cloneSession` and
`cloneSessionWithSessionID`, which verify that the cloned session inherits SQL
configurations and temporary views and that subsequent changes to either
session are isolated from the other. The tests are guarded to run on Apache
Spark 4.1+ servers, and were verified manually against a local Apache Spark
4.2.0 Connect server.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]