Skip to content

Commit b15c15f

Browse files
committed
Handle Spark 3
1 parent ebfd2cb commit b15c15f

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

Tests/SparkConnectTests/MergeIntoWriterTests.swift

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,20 @@ struct MergeIntoWriterTests {
3131
let tableName = "TABLE_" + UUID().uuidString.replacingOccurrences(of: "-", with: "")
3232
try await SQLHelper.withTable(spark, tableName)({
3333
let mergeInto = try await spark.range(1).mergeInto(tableName, "true")
34-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
35-
try await mergeInto.whenMatched().delete().merge()
36-
}
37-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
38-
try await mergeInto.whenMatched("true").delete().merge()
34+
if await spark.version >= "4.0.0" {
35+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
36+
try await mergeInto.whenMatched().delete().merge()
37+
}
38+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
39+
try await mergeInto.whenMatched("true").delete().merge()
40+
}
41+
} else {
42+
try await #require(throws: Error.self) {
43+
try await mergeInto.whenMatched().delete().merge()
44+
}
45+
try await #require(throws: Error.self) {
46+
try await mergeInto.whenMatched("true").delete().merge()
47+
}
3948
}
4049
})
4150
await spark.stop()
@@ -47,11 +56,20 @@ struct MergeIntoWriterTests {
4756
let tableName = "TABLE_" + UUID().uuidString.replacingOccurrences(of: "-", with: "")
4857
try await SQLHelper.withTable(spark, tableName)({
4958
let mergeInto = try await spark.range(1).mergeInto(tableName, "true")
50-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
51-
try await mergeInto.whenNotMatched().insertAll().merge()
52-
}
53-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
54-
try await mergeInto.whenNotMatched("true").insertAll().merge()
59+
if await spark.version >= "4.0.0" {
60+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
61+
try await mergeInto.whenNotMatched().insertAll().merge()
62+
}
63+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
64+
try await mergeInto.whenNotMatched("true").insertAll().merge()
65+
}
66+
} else {
67+
try await #require(throws: Error.self) {
68+
try await mergeInto.whenNotMatched().insertAll().merge()
69+
}
70+
try await #require(throws: Error.self) {
71+
try await mergeInto.whenNotMatched("true").insertAll().merge()
72+
}
5573
}
5674
})
5775
await spark.stop()
@@ -63,11 +81,20 @@ struct MergeIntoWriterTests {
6381
let tableName = "TABLE_" + UUID().uuidString.replacingOccurrences(of: "-", with: "")
6482
try await SQLHelper.withTable(spark, tableName)({
6583
let mergeInto = try await spark.range(1).mergeInto(tableName, "true")
66-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
67-
try await mergeInto.whenNotMatchedBySource().delete().merge()
68-
}
69-
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
70-
try await mergeInto.whenNotMatchedBySource("true").delete().merge()
84+
if await spark.version >= "4.0.0" {
85+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
86+
try await mergeInto.whenNotMatchedBySource().delete().merge()
87+
}
88+
try await #require(throws: SparkConnectError.TableOrViewNotFound) {
89+
try await mergeInto.whenNotMatchedBySource("true").delete().merge()
90+
}
91+
} else {
92+
try await #require(throws: Error.self) {
93+
try await mergeInto.whenNotMatchedBySource().delete().merge()
94+
}
95+
try await #require(throws: Error.self) {
96+
try await mergeInto.whenNotMatchedBySource("true").delete().merge()
97+
}
7198
}
7299
})
73100
await spark.stop()

0 commit comments

Comments
 (0)