Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/SparkConnect/SparkSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public actor SparkSession {
/// The Spark version of Spark Connect Servier. This is supposed to be overwritten during establishing connections.
public var version: String = ""

/// Start a new session with isolated SQL configurations, temporary tables, registered functions
/// are isolated, but sharing the underlying `SparkContext` and cached data.
/// - Returns: a new ``SparkSession`` instance.
public func newSession() async throws -> SparkSession {
return try await SparkSession.builder.create()
}

func setVersion(_ version: String) {
self.version = version
}
Expand Down
10 changes: 10 additions & 0 deletions Tests/SparkConnectTests/SparkSessionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ struct SparkSessionTests {
await spark.stop()
}

@Test
func newSession() async throws {
let spark = try await SparkSession.builder.getOrCreate()
await spark.stop()
let newSpark = try await spark.newSession()
#expect(newSpark != spark)
#expect(try await newSpark.range(1).count() == 1)
await newSpark.stop()
}

@Test func userContext() async throws {
let spark = try await SparkSession.builder.getOrCreate()
#if os(macOS) || os(Linux)
Expand Down
Loading