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
3 changes: 3 additions & 0 deletions Sources/SparkConnect/DataFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public actor DataFrame: Sendable {

/// Execute the plan and try to fill `schema` and `batches`.
private func execute() async throws {
// Clear all existing batches.
self.batches.removeAll()

try await withGRPCClient(
transport: .http2NIOPosix(
target: .dns(host: spark.client.host, port: spark.client.port),
Expand Down
9 changes: 9 additions & 0 deletions Tests/SparkConnectTests/DataFrameTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ struct DataFrameTests {
await spark.stop()
}

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

@Test
func head() async throws {
let spark = try await SparkSession.builder.getOrCreate()
Expand Down
Loading