Skip to content

Commit 45ddf7b

Browse files
committed
Add DataFrameWriterV2Tests
1 parent 8a2ef58 commit 45ddf7b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,5 @@ jobs:
158158
cd /tmp/spark/sbin
159159
./start-connect-server.sh --packages org.apache.spark:spark-connect_2.12:3.5.5,org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.9.0 -c spark.sql.catalog.local=org.apache.iceberg.spark.SparkCatalog -c spark.sql.catalog.local.type=hadoop -c spark.sql.catalog.local.warehouse=/tmp/spark/warehouse -c spark.sql.defaultCatalog=local
160160
cd -
161+
swift test --filter DataFrameWriterV2Tests -c release
161162
swift test --filter IcebergTest -c release

Tests/SparkConnectTests/DataFrameWriterV2Tests.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Testing
2424
/// A test suite for `DataFrameWriterV2`
2525
@Suite(.serialized)
2626
struct DataFrameWriterV2Tests {
27+
let icebergEnabled = ProcessInfo.processInfo.environment["SPARK_ICEBERG_TEST_ENABLED"] != nil
2728

2829
@Test
2930
func create() async throws {
@@ -48,9 +49,12 @@ struct DataFrameWriterV2Tests {
4849
let write = try await spark.range(2).writeTo(tableName).using("orc")
4950
try await write.create()
5051
#expect(try await spark.table(tableName).count() == 2)
51-
// TODO: Use Iceberg to verify success case after Iceberg supports Apache Spark 4
52-
try await #require(throws: Error.self) {
52+
if icebergEnabled {
5353
try await write.createOrReplace()
54+
} else {
55+
try await #require(throws: Error.self) {
56+
try await write.createOrReplace()
57+
}
5458
}
5559
})
5660
await spark.stop()
@@ -64,9 +68,12 @@ struct DataFrameWriterV2Tests {
6468
let write = try await spark.range(2).writeTo(tableName).using("orc")
6569
try await write.create()
6670
#expect(try await spark.table(tableName).count() == 2)
67-
// TODO: Use Iceberg to verify success case after Iceberg supports Apache Spark 4
68-
try await #require(throws: Error.self) {
71+
if icebergEnabled {
6972
try await write.replace()
73+
} else {
74+
try await #require(throws: Error.self) {
75+
try await write.replace()
76+
}
7077
}
7178
})
7279
await spark.stop()
@@ -80,9 +87,12 @@ struct DataFrameWriterV2Tests {
8087
let write = try await spark.range(2).writeTo(tableName).using("orc")
8188
try await write.create()
8289
#expect(try await spark.table(tableName).count() == 2)
83-
// TODO: Use Iceberg to verify success case after Iceberg supports Apache Spark 4
84-
try await #require(throws: Error.self) {
90+
if icebergEnabled {
8591
try await write.append()
92+
} else {
93+
try await #require(throws: Error.self) {
94+
try await write.append()
95+
}
8696
}
8797
})
8898
await spark.stop()

0 commit comments

Comments
 (0)