2323from parquet_test_utils import parquet_row_group_midpoints
2424from spark_session import with_cpu_session , with_gpu_session , is_databricks_runtime , \
2525 is_spark_320_or_later , is_spark_340_or_later , supports_delta_lake_deletion_vectors , is_spark_401_or_later , \
26- is_before_spark_353 , is_databricks173_or_later
26+ gpu_supports_delta_dv_scan , is_before_spark_353 , is_databricks173_or_later
2727
2828_conf = {'spark.rapids.sql.explain' : 'ALL' }
2929
@@ -198,15 +198,8 @@ def test_delta_deletion_vector_read(spark_tmp_path, chunk_size, use_cdf, dv_pred
198198cdf_fallback = ["RowDataSourceScanExec" ]
199199
200200
201- @allow_non_gpu (* cdf_fallback , * delta_meta_allow )
202- @delta_lake
203- @ignore_order (local = True )
204- @pytest .mark .parametrize ("chunk_size" , ["2000" , "4000" , None ], ids = idfn )
205- @pytest .mark .parametrize ("parquet_reader_type" , ["PERFILE" , "COALESCING" , "MULTITHREADED" ], ids = idfn )
206- @pytest .mark .skipif (not supports_delta_lake_deletion_vectors (),
207- reason = "Delta Lake deletion vector support is required" )
208- @pytest .mark .skipif (is_databricks_runtime (), reason = "https://github.com/NVIDIA/cudf-spark/issues/15365" )
209- def test_delta_deletion_vector_read_with_cdf (spark_tmp_path , chunk_size , parquet_reader_type ):
201+ def _test_delta_deletion_vector_read_with_cdf (
202+ spark_tmp_path , chunk_size , parquet_reader_type , expect_fallback ):
210203 data_path = spark_tmp_path + "/DELTA_DATA"
211204 conf = {"spark.databricks.delta.delete.deletionVectors.persistent" : "true" ,
212205 "spark.rapids.sql.reader.chunked" : f"{ chunk_size is not None } " ,
@@ -220,10 +213,46 @@ def test_delta_deletion_vector_read_with_cdf(spark_tmp_path, chunk_size, parquet
220213 "DELETE FROM delta.`{}` WHERE a = 1" .format (data_path )
221214 ])
222215
223- assert_gpu_and_cpu_are_equal_collect (
224- lambda spark : read_delta_path_with_cdf (spark , data_path ),
225- conf = conf
226- )
216+ def read_cdf (spark ):
217+ return read_delta_path_with_cdf (spark , data_path )
218+
219+ if expect_fallback :
220+ # DeltaCDFRelation hides its internal file scan behind this V1 CPU scan.
221+ assert_gpu_fallback_collect (
222+ read_cdf ,
223+ "RowDataSourceScanExec" ,
224+ conf = conf )
225+ else :
226+ assert_gpu_and_cpu_are_equal_collect (read_cdf , conf = conf )
227+
228+
229+ @allow_non_gpu (* cdf_fallback , * delta_meta_allow )
230+ @delta_lake
231+ @ignore_order (local = True )
232+ @pytest .mark .parametrize ("chunk_size" , ["2000" , "4000" , None ], ids = idfn )
233+ @pytest .mark .parametrize ("parquet_reader_type" , ["PERFILE" , "COALESCING" , "MULTITHREADED" ], ids = idfn )
234+ @pytest .mark .skipif (not gpu_supports_delta_dv_scan (),
235+ reason = "GPU Delta deletion vector scan support is required" )
236+ @pytest .mark .skipif (is_databricks_runtime (), reason = "https://github.com/NVIDIA/cudf-spark/issues/15365" )
237+ def test_delta_deletion_vector_read_with_cdf (spark_tmp_path , chunk_size , parquet_reader_type ):
238+ _test_delta_deletion_vector_read_with_cdf (
239+ spark_tmp_path , chunk_size , parquet_reader_type , expect_fallback = False )
240+
241+
242+ @allow_non_gpu ("ColumnarToRowExec" , * cdf_fallback , * delta_meta_allow )
243+ @delta_lake
244+ @ignore_order (local = True )
245+ @pytest .mark .parametrize ("chunk_size" , ["2000" , "4000" , None ], ids = idfn )
246+ @pytest .mark .parametrize ("parquet_reader_type" , ["PERFILE" , "COALESCING" , "MULTITHREADED" ], ids = idfn )
247+ @pytest .mark .skipif (not supports_delta_lake_deletion_vectors (),
248+ reason = "Delta Lake deletion vector feature is required" )
249+ @pytest .mark .skipif (gpu_supports_delta_dv_scan (),
250+ reason = "GPU Delta deletion vector scans are supported" )
251+ @pytest .mark .skipif (is_databricks_runtime (), reason = "https://github.com/NVIDIA/cudf-spark/issues/15365" )
252+ def test_delta_deletion_vector_read_with_cdf_fallback (
253+ spark_tmp_path , chunk_size , parquet_reader_type ):
254+ _test_delta_deletion_vector_read_with_cdf (
255+ spark_tmp_path , chunk_size , parquet_reader_type , expect_fallback = True )
227256
228257
229258def _create_delta_cdf_mixed_filter_files (spark , data_path , second_file_partition ):
@@ -591,10 +620,10 @@ def setup_tables(spark):
591620 conf = conf )
592621
593622
594- @allow_non_gpu ("FileSourceScanExec" , "ColumnarToRowExec" , * delta_meta_allow )
623+ @allow_non_gpu (* delta_meta_allow )
595624@delta_lake
596- @pytest .mark .skipif (not supports_delta_lake_deletion_vectors (),
597- reason = "Delta Lake deletion vector support is required" )
625+ @pytest .mark .skipif (not gpu_supports_delta_dv_scan (),
626+ reason = "GPU Delta deletion vector scan support is required" )
598627@pytest .mark .skipif (is_databricks_runtime (),
599628 reason = "This test targets the OSS multithreaded Delta reader" )
600629def test_delta_deletion_vector_multithreaded_combine_count_star_mixed_dv_no_dv (
0 commit comments