Skip to content

Commit a2c2b6a

Browse files
authored
DV read tests with cdf should run with spark 353+ [databricks] (NVIDIA#15462)
Fixes NVIDIA#15461. ### Description Two new integration tests are failing in the pre-release CI. These tests test the deletion vector read with CDF enabled. Since these tests require the DV scan to run on GPU, they should run with Spark 3.5.3+ which are the versions the plugin accelerates the DV scan. One related issue is the confusing name of the `supports_delta_lake_deletion_vectors` function. The "support" can mean different things depending on the context. In the plugin context, supporting DV means that the DV scan runs on GPU. In the Delta Lake context, supporting DV means that the deletion vector feature is supported. The function in question is confusing as it does not tell what supports deletion vectors, and thus what is the meaning of supporting deletion vectors. This PR fixes the problems above by adding a new function `gpu_supports_delta_dv_scan`, which returns true if the DV scan runs on GPU in the given runtime. The failing tests now use `gpu_supports_delta_dv_scan` to skip themselves for Spark 3.4.x. A new test is also added to test the fallback with Spark 3.4.x. The failing tests and the new tests are manually tested with Spark 3.5.5 and 3.4.4. I will make another PR to rename the confusing `supports_delta_lake_deletion_vectors` against the main branch. ### Checklists Documentation - [ ] Updated for new or modified user-facing features or behaviors - [x] No user-facing change Testing - [x] Added or modified tests to cover new code paths - [ ] Covered by existing tests (Please provide the names of the existing tests in the PR description.) - [ ] Not required Performance - [ ] Tests ran and results are added in the PR description - [ ] Issue filed with a link in the PR description - [x] Not required --------- Signed-off-by: Jihoon Son <ghoonson@gmail.com>
1 parent c69e922 commit a2c2b6a

2 files changed

Lines changed: 54 additions & 17 deletions

File tree

integration_tests/src/main/python/delta_lake_test.py

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from parquet_test_utils import parquet_row_group_midpoints
2424
from 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
198198
cdf_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

229258
def _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")
600629
def test_delta_deletion_vector_multithreaded_combine_count_star_mixed_dv_no_dv(

integration_tests/src/main/python/spark_session.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,19 @@ def is_databricks173_or_later():
335335
return is_databricks_version_or_later(17, 3)
336336

337337
def supports_delta_lake_deletion_vectors():
338+
"""Whether the current Delta Lake runtime provides the deletion-vector feature."""
338339
if is_databricks_runtime():
339340
return is_databricks122_or_later()
340341
else:
341342
return is_spark_340_or_later()
342343

344+
def gpu_supports_delta_dv_scan():
345+
"""Whether RAPIDS supports scanning Delta deletion vectors on the GPU."""
346+
if is_databricks_runtime():
347+
return is_databricks173_or_later()
348+
else:
349+
return is_spark_353_or_later()
350+
343351
def is_support_default_values_in_schema():
344352
# Spark 340 + and Databricks 330 + support
345353
return is_spark_340_or_later() or is_databricks113_or_later()

0 commit comments

Comments
 (0)