-
Notifications
You must be signed in to change notification settings - Fork 292
Add set based operations for arrays: array_intersect, array_union, array_except, and arrays_overlap for running on GPU
#5958
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
Merged
revans2
merged 23 commits into
NVIDIA:branch-22.08
from
NVnavkumar:array_intersect_string_array
Aug 2, 2022
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8ddb9fc
WIP: Plugin implementation of array_intersect using setIntersect, sor…
NVnavkumar 0367a78
WIP: array_intersect
NVnavkumar 7743f45
array_intersect implementation
NVnavkumar 64946b2
implementation of 3 other array set operations
NVnavkumar ef54c68
add integration tests
NVnavkumar 3362c08
working versions of array_difference and arrays_overlap
NVnavkumar 728f15a
array_union passing tests but for one strange bug in GPU partitioning
NVnavkumar 18ad1c0
Merge branch 'branch-22.08' of github.com:NVIDIA/spark-rapids into ar…
NVnavkumar 3bfe106
cleanup arrays_overlap integration test
NVnavkumar c8e21b6
Add reference to issue filed regarding partitioning and collect()
NVnavkumar e7f978c
Merge branch 'branch-22.08' of github.com:NVIDIA/spark-rapids into ar…
NVnavkumar fab15a1
Add clarifying comment for GpuArraysOverlap
NVnavkumar f1003c4
Update integration_tests/src/main/python/array_test.py
NVnavkumar eb5e6f4
make generated arrays nullable in integration tests
NVnavkumar 06af5eb
remove the plugin code for null return value handling since this is n…
NVnavkumar 62fcdba
Merge branch 'branch-22.08' into array_intersect_string_array
NVnavkumar cd6beb2
Refactor to using GpuComplexTypeMergingExpression
NVnavkumar 4587238
Add decimal_gens to testing here
NVnavkumar d2c8911
ensure all other special cases for floats and doubles are here except…
NVnavkumar 893f7d0
Updated docs and xfail Double and Float tests on Spark versions < 3.1.3
NVnavkumar 494ad54
Merge branch 'branch-22.08' into array_intersect_string_array
NVnavkumar 3a83257
Updated references to methods in cudf and added some scalar tests
NVnavkumar 5736e1e
Add incompat documentation, and update tests to handle pre Spark 3.1.…
NVnavkumar 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 hidden or 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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -394,3 +394,80 @@ def test_array_max_q1(): | |||||||
| def q1(spark): | ||||||||
| return spark.sql('SELECT ARRAY_MAX(TRANSFORM(ARRAY_REPEAT(STRUCT(1, 2), 0), s -> s.col2))') | ||||||||
| assert_gpu_and_cpu_are_equal_collect(q1) | ||||||||
|
|
||||||||
|
|
||||||||
| @pytest.mark.parametrize('data_gen', [byte_gen, short_gen, int_gen, long_gen, | ||||||||
| FloatGen(special_cases=[]), DoubleGen(special_cases=[]), string_gen, boolean_gen, date_gen, timestamp_gen], ids=idfn) | ||||||||
|
jlowe marked this conversation as resolved.
Outdated
|
||||||||
| def test_array_intersect(data_gen): | ||||||||
| gen = StructGen( | ||||||||
| [('a', ArrayGen(data_gen, nullable=False)), | ||||||||
| ('b', ArrayGen(data_gen, nullable=False))], | ||||||||
|
ttnghia marked this conversation as resolved.
Outdated
|
||||||||
| nullable=False) | ||||||||
|
|
||||||||
| assert_gpu_and_cpu_are_equal_collect( | ||||||||
| lambda spark: gen_df(spark, gen).selectExpr( | ||||||||
| 'sort_array(array_intersect(a, b))', | ||||||||
| 'sort_array(array_intersect(b, a))', | ||||||||
| 'sort_array(array_intersect(a, array()))', | ||||||||
| 'sort_array(array_intersect(array(), b))', | ||||||||
| 'sort_array(array_intersect(a, a))', | ||||||||
| ) | ||||||||
| ) | ||||||||
|
|
||||||||
| @pytest.mark.parametrize('data_gen', [byte_gen, short_gen, int_gen, long_gen, | ||||||||
| FloatGen(special_cases=[]), DoubleGen(special_cases=[]), string_gen, boolean_gen, date_gen, timestamp_gen], ids=idfn) | ||||||||
| def test_array_union(data_gen): | ||||||||
| gen = StructGen( | ||||||||
| [('a', ArrayGen(data_gen, nullable=False)), | ||||||||
| ('b', ArrayGen(data_gen, nullable=False))], | ||||||||
| nullable=False) | ||||||||
|
|
||||||||
| # The 4th item in this integration test here is left commmented out here | ||||||||
|
NVnavkumar marked this conversation as resolved.
Outdated
|
||||||||
| # There is an issue with running that item with collect(), which affects | ||||||||
| # the integration test here. | ||||||||
| # See this issue (https://github.com/NVIDIA/spark-rapids/issues/5957) | ||||||||
| assert_gpu_and_cpu_are_equal_collect( | ||||||||
| lambda spark: gen_df(spark, gen).selectExpr( | ||||||||
| 'sort_array(array_union(a, b))', | ||||||||
| 'sort_array(array_union(b, a))', | ||||||||
| 'sort_array(array_union(a, array()))', | ||||||||
| # 'sort_array(array_union(array(), b))', # see https://github.com/NVIDIA/spark-rapids/issues/5957 | ||||||||
|
NVnavkumar marked this conversation as resolved.
Outdated
|
||||||||
| 'sort_array(array_union(a, a))', | ||||||||
| ) | ||||||||
| ) | ||||||||
|
|
||||||||
| @pytest.mark.parametrize('data_gen', [byte_gen, short_gen, int_gen, long_gen, | ||||||||
| FloatGen(special_cases=[]), DoubleGen(special_cases=[]), string_gen, boolean_gen, date_gen, timestamp_gen], ids=idfn) | ||||||||
| def test_array_except(data_gen): | ||||||||
| gen = StructGen( | ||||||||
| [('a', ArrayGen(data_gen, nullable=False)), | ||||||||
| ('b', ArrayGen(data_gen, nullable=False))], | ||||||||
| nullable=False) | ||||||||
|
|
||||||||
| assert_gpu_and_cpu_are_equal_collect( | ||||||||
| lambda spark: gen_df(spark, gen).selectExpr( | ||||||||
| 'sort_array(array_except(a, b))', | ||||||||
| 'sort_array(array_except(b, a))', | ||||||||
| 'sort_array(array_except(a, array()))', | ||||||||
| 'sort_array(array_except(array(), b))', | ||||||||
| 'sort_array(array_except(a, a))', | ||||||||
| ) | ||||||||
| ) | ||||||||
|
|
||||||||
| @pytest.mark.parametrize('data_gen', [byte_gen, short_gen, int_gen, long_gen, | ||||||||
| FloatGen(special_cases=[]), DoubleGen(special_cases=[]), string_gen, boolean_gen, date_gen, timestamp_gen], ids=idfn) | ||||||||
| def test_arrays_overlap(data_gen): | ||||||||
| gen = StructGen( | ||||||||
| [('a', ArrayGen(data_gen, nullable=False)), | ||||||||
| ('b', ArrayGen(data_gen, nullable=False))], | ||||||||
| nullable=False) | ||||||||
|
|
||||||||
| assert_gpu_and_cpu_are_equal_collect( | ||||||||
| lambda spark: gen_df(spark, gen).selectExpr( | ||||||||
| 'arrays_overlap(a, b)', | ||||||||
| 'arrays_overlap(b, a)', | ||||||||
| 'arrays_overlap(a, array())', | ||||||||
| 'arrays_overlap(array(), b)', | ||||||||
| 'arrays_overlap(a, a)', | ||||||||
| ) | ||||||||
| ) | ||||||||
|
Collaborator
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. There should be an empty line at the end of the file as an implicit convention.
Suggested change
|
||||||||
This file contains hidden or 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
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.