-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve some CSV integration tests [databricks] #9146
Merged
andygrove
merged 8 commits into
NVIDIA:branch-23.10
from
andygrove:csv-test-improvements
Sep 28, 2023
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3f38a68
improve some csv tests
andygrove df1ce81
remove unrelated change
andygrove c1d5397
remove unrelated test
andygrove b554ed0
use named parameters to improve readability
andygrove 4efd6aa
remove trailing comma
andygrove b6d1258
update comment
andygrove 629b4f2
address feedback (add link to issue for future improvements)
andygrove 68506b6
Merge branch 'branch-23.10' into csv-test-improvements
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -463,14 +463,15 @@ def test_input_meta_fallback(spark_tmp_path, v1_enabled_list, disable_conf): | |
updated_conf = copy_and_update(_enable_all_types_conf, { | ||
'spark.sql.sources.useV1SourceList': v1_enabled_list, | ||
disable_conf: 'false'}) | ||
assert_gpu_and_cpu_are_equal_collect( | ||
assert_gpu_fallback_collect( | ||
lambda spark : spark.read.schema(gen.data_type)\ | ||
.csv(data_path)\ | ||
.filter(f.col('a') > 0)\ | ||
.selectExpr('a', | ||
'input_file_name()', | ||
'input_file_block_start()', | ||
'input_file_block_length()'), | ||
cpu_fallback_class_name = 'FileSourceScanExec' if v1_enabled_list == 'csv' else 'BatchScanExec', | ||
conf=updated_conf) | ||
|
||
@allow_non_gpu('DataWritingCommandExec,ExecutedCommandExec,WriteFilesExec') | ||
|
@@ -529,16 +530,18 @@ def test_round_trip_for_interval(spark_tmp_path, v1_enabled_list): | |
lambda spark: spark.read.schema(schema).csv(data_path), | ||
conf=updated_conf) | ||
|
||
@allow_non_gpu(any = True) | ||
@allow_non_gpu('FileSourceScanExec', 'CollectLimitExec', 'DeserializeToObjectExec') | ||
def test_csv_read_case_insensitivity(spark_tmp_path): | ||
gen_list = [('one', int_gen), ('tWo', byte_gen), ('THREE', boolean_gen)] | ||
data_path = spark_tmp_path + '/CSV_DATA' | ||
|
||
with_cpu_session(lambda spark: gen_df(spark, gen_list).write.option('header', True).csv(data_path)) | ||
|
||
assert_gpu_and_cpu_are_equal_collect( | ||
assert_cpu_and_gpu_are_equal_collect_with_capture( | ||
lambda spark: spark.read.option('header', True).csv(data_path).select('one', 'two', 'three'), | ||
{'spark.sql.caseSensitive': 'false'} | ||
exist_classes = 'GpuFileSourceScanExec', | ||
non_exist_classes = 'FileSourceScanExec', | ||
conf = {'spark.sql.caseSensitive': 'false'} | ||
) | ||
|
||
@allow_non_gpu('FileSourceScanExec', 'CollectLimitExec', 'DeserializeToObjectExec') | ||
|
@@ -549,7 +552,10 @@ def test_csv_read_count(spark_tmp_path): | |
|
||
with_cpu_session(lambda spark: gen_df(spark, gen_list).write.csv(data_path)) | ||
|
||
assert_gpu_and_cpu_row_counts_equal(lambda spark: spark.read.csv(data_path)) | ||
# TODO this does not confirm that this scan actually runs on GPU, but I am not | ||
# sure if we can capture the plan with a COUNT, since it normally requires a COLLECT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let us file an issue and maybe reference it in the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @gerashegalov . I have filed #9199 and updated the comment. |
||
assert_gpu_and_cpu_row_counts_equal(lambda spark: spark.read.csv(data_path), | ||
conf = {'spark.rapids.sql.explain': 'ALL'}) | ||
|
||
@allow_non_gpu('FileSourceScanExec', 'CollectLimitExec', 'DeserializeToObjectExec') | ||
@pytest.mark.skipif(is_before_spark_340(), reason='`preferDate` is only supported in Spark 340+') | ||
|
@@ -561,12 +567,18 @@ def test_csv_prefer_date_with_infer_schema(spark_tmp_path): | |
|
||
with_cpu_session(lambda spark: gen_df(spark, gen_list).write.csv(data_path)) | ||
|
||
assert_gpu_and_cpu_are_equal_collect(lambda spark: spark.read.option("inferSchema", "true").csv(data_path)) | ||
assert_gpu_and_cpu_are_equal_collect(lambda spark: spark.read.option("inferSchema", "true").option("preferDate", "false").csv(data_path)) | ||
assert_cpu_and_gpu_are_equal_collect_with_capture( | ||
lambda spark: spark.read.option("inferSchema", "true").csv(data_path), | ||
exist_classes = 'GpuFileSourceScanExec', | ||
non_exist_classes = 'FileSourceScanExec') | ||
assert_cpu_and_gpu_are_equal_collect_with_capture( | ||
lambda spark: spark.read.option("inferSchema", "true").option("preferDate", "false").csv(data_path), | ||
exist_classes = 'GpuFileSourceScanExec', | ||
non_exist_classes = 'FileSourceScanExec') | ||
|
||
@allow_non_gpu('FileSourceScanExec') | ||
@pytest.mark.skipif(is_before_spark_340(), reason='enableDateTimeParsingFallback is supported from Spark3.4.0') | ||
@pytest.mark.parametrize('filename,schema',[("date.csv", _date_schema), ("date.csv", _ts_schema,), | ||
@pytest.mark.parametrize('filename,schema',[("date.csv", _date_schema), ("date.csv", _ts_schema), | ||
("ts.csv", _ts_schema)]) | ||
def test_csv_datetime_parsing_fallback_cpu_fallback(std_input_path, filename, schema): | ||
data_path = std_input_path + "/" + filename | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a must-fix, stylistically and because in a future the parameter
v1_enabled_list
might become a comma-separated value or a Python list we might want to check for'csv' in v1_enabled_list
rather than equality.