@@ -24,6 +24,7 @@ import Testing
2424/// A test suite for `DataFrameWriterV2`
2525@Suite ( . serialized)
2626struct 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