@@ -26,7 +26,7 @@ import java.util.UUID
2626import org .apache .commons .io .FileUtils
2727import org .apache .spark .SparkConf
2828import org .apache .spark .sql .{CometTestBase , DataFrame , SaveMode }
29- import org .apache .spark .sql .comet .CometNativeScanExec
29+ import org .apache .spark .sql .comet .{ CometNativeScanExec , CometScanExec }
3030import org .apache .spark .sql .execution .adaptive .AdaptiveSparkPlanHelper
3131import org .apache .spark .sql .functions .{col , sum }
3232
@@ -62,16 +62,21 @@ class ParquetReadFromFakeHadoopFsSuite extends CometTestBase with AdaptiveSparkP
6262 }
6363
6464 private def assertCometNativeScanOnFakeFs (df : DataFrame ): Unit = {
65- val scans = collect(df.queryExecution.executedPlan) { case p : CometNativeScanExec =>
66- p
65+ val scans = collect(df.queryExecution.executedPlan) {
66+ case p : CometNativeScanExec =>
67+ assert(
68+ p.nativeOp.getNativeScan
69+ .getFilePartitions(0 )
70+ .getPartitionedFile(0 )
71+ .getFilePath
72+ .startsWith(FakeHDFSFileSystem .PREFIX ))
73+ p
74+ case p : CometScanExec if p.scanImpl == CometConf .SCAN_NATIVE_ICEBERG_COMPAT =>
75+ assert(p.toString().contains(FakeHDFSFileSystem .PREFIX ))
76+ p
6777 }
6878 assert(scans.size == 1 )
69- assert(
70- scans.head.nativeOp.getNativeScan
71- .getFilePartitions(0 )
72- .getPartitionedFile(0 )
73- .getFilePath
74- .startsWith(FakeHDFSFileSystem .PREFIX ))
79+
7580 }
7681
7782 test(" test native_datafusion scan on fake fs" ) {
@@ -80,10 +85,13 @@ class ParquetReadFromFakeHadoopFsSuite extends CometTestBase with AdaptiveSparkP
8085 val testFilePath =
8186 s " ${FakeHDFSFileSystem .PREFIX }${fake_root_dir.getAbsolutePath}/data/test-file.parquet "
8287 writeTestParquetFile(testFilePath)
83- withSQLConf(CometConf .COMET_NATIVE_SCAN_IMPL .key -> CometConf .SCAN_NATIVE_DATAFUSION ) {
84- val df = spark.read.format(" parquet" ).load(testFilePath).agg(sum(col(" id" )))
85- assertCometNativeScanOnFakeFs(df)
86- assert(df.first().getLong(0 ) == 499500 )
88+ Seq (CometConf .SCAN_NATIVE_DATAFUSION , CometConf .SCAN_NATIVE_ICEBERG_COMPAT ).foreach {
89+ scanImpl =>
90+ withSQLConf(CometConf .COMET_NATIVE_SCAN_IMPL .key -> scanImpl) {
91+ val df = spark.read.format(" parquet" ).load(testFilePath).agg(sum(col(" id" )))
92+ assertCometNativeScanOnFakeFs(df)
93+ assert(df.first().getLong(0 ) == 499500 )
94+ }
8795 }
8896 }
8997}
0 commit comments