File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ public actor DataFrame: Sendable {
62
62
self . batches. append ( contentsOf: batches)
63
63
}
64
64
65
+ /// Return the `SparkSession` of this `DataFrame`.
66
+ /// - Returns: A `SparkSession`
67
+ public func sparkSession( ) -> SparkSession {
68
+ return self . spark
69
+ }
70
+
65
71
/// A method to access the underlying Spark's `RDD`.
66
72
/// In `Spark Connect`, this feature is not allowed by design.
67
73
public func rdd( ) throws {
Original file line number Diff line number Diff line change @@ -77,3 +77,9 @@ extension Data {
77
77
/// Get an `Int32` value from unsafe 4 bytes.
78
78
var int32 : Int32 { withUnsafeBytes ( { $0. load ( as: Int32 . self) } ) }
79
79
}
80
+
81
+ extension SparkSession : Equatable {
82
+ public static func == ( lhs: SparkSession , rhs: SparkSession ) -> Bool {
83
+ return lhs. sessionID == rhs. sessionID
84
+ }
85
+ }
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public actor SparkSession {
62
62
}
63
63
64
64
/// A unique session ID for this session from client.
65
- var sessionID : String = UUID ( ) . uuidString
65
+ nonisolated let sessionID : String = UUID ( ) . uuidString
66
66
67
67
/// Get the current session ID
68
68
/// - Returns: the current session ID
Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ import Testing
23
23
24
24
/// A test suite for `DataFrame`
25
25
struct DataFrameTests {
26
+ @Test
27
+ func sparkSession( ) async throws {
28
+ let spark = try await SparkSession . builder. getOrCreate ( )
29
+ #expect( try await spark. range ( 1 ) . sparkSession ( ) == spark)
30
+ await spark. stop ( )
31
+ }
32
+
26
33
@Test
27
34
func rdd( ) async throws {
28
35
let spark = try await SparkSession . builder. getOrCreate ( )
You can’t perform that action at this time.
0 commit comments