-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-28278][SQL][PYTHON][TESTS] Convert and port 'except-all.sql' into UDF test base #25090
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bcba95a
initial commit
imback82 a512ef8
fix comments.
imback82 b1d1d6b
Merge branch 'master' into except-all
imback82 a09df4b
Addressing PR comments
imback82 ce1e36b
Merge branch 'master' into except-all
imback82 2c8cc19
Address PR comments
imback82 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
162 changes: 162 additions & 0 deletions
162
sql/core/src/test/resources/sql-tests/inputs/udf/udf-except-all.sql
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 |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| -- This test file was converted from except-all.sql. | ||
|
|
||
| CREATE TEMPORARY VIEW tab1 AS SELECT * FROM VALUES | ||
| (0), (1), (2), (2), (2), (2), (3), (null), (null) AS tab1(c1); | ||
| CREATE TEMPORARY VIEW tab2 AS SELECT * FROM VALUES | ||
| (1), (2), (2), (3), (5), (5), (null) AS tab2(c1); | ||
| CREATE TEMPORARY VIEW tab3 AS SELECT * FROM VALUES | ||
| (1, 2), | ||
| (1, 2), | ||
| (1, 3), | ||
| (2, 3), | ||
| (2, 2) | ||
| AS tab3(k, v); | ||
| CREATE TEMPORARY VIEW tab4 AS SELECT * FROM VALUES | ||
| (1, 2), | ||
| (2, 3), | ||
| (2, 2), | ||
| (2, 2), | ||
| (2, 20) | ||
| AS tab4(k, v); | ||
|
|
||
| -- Basic EXCEPT ALL | ||
| SELECT udf(c1) FROM tab1 | ||
| EXCEPT ALL | ||
| SELECT udf(c1) FROM tab2; | ||
|
|
||
| -- MINUS ALL (synonym for EXCEPT) | ||
| SELECT udf(c1) FROM tab1 | ||
| MINUS ALL | ||
| SELECT udf(c1) FROM tab2; | ||
|
|
||
| -- EXCEPT ALL same table in both branches | ||
| SELECT udf(c1) FROM tab1 | ||
| EXCEPT ALL | ||
| SELECT udf(c1) FROM tab2 WHERE udf(c1) IS NOT NULL; | ||
|
|
||
| -- Empty left relation | ||
| SELECT udf(c1) FROM tab1 WHERE udf(c1) > 5 | ||
| EXCEPT ALL | ||
| SELECT udf(c1) FROM tab2; | ||
|
|
||
| -- Empty right relation | ||
| SELECT udf(c1) FROM tab1 | ||
| EXCEPT ALL | ||
| SELECT udf(c1) FROM tab2 WHERE udf(c1 > udf(6)); | ||
|
|
||
| -- Type Coerced ExceptAll | ||
| SELECT udf(c1) FROM tab1 | ||
| EXCEPT ALL | ||
| SELECT CAST(udf(1) AS BIGINT); | ||
|
|
||
| -- Error as types of two side are not compatible | ||
| SELECT udf(c1) FROM tab1 | ||
| EXCEPT ALL | ||
| SELECT array(1); | ||
|
imback82 marked this conversation as resolved.
|
||
|
|
||
| -- Basic | ||
| SELECT udf(k), v FROM tab3 | ||
| EXCEPT ALL | ||
| SELECT k, udf(v) FROM tab4; | ||
|
|
||
| -- Basic | ||
| SELECT k, udf(v) FROM tab4 | ||
| EXCEPT ALL | ||
| SELECT udf(k), v FROM tab3; | ||
|
|
||
| -- EXCEPT ALL + INTERSECT | ||
| SELECT udf(k), udf(v) FROM tab4 | ||
| EXCEPT ALL | ||
| SELECT udf(k), udf(v) FROM tab3 | ||
| INTERSECT DISTINCT | ||
| SELECT udf(k), udf(v) FROM tab4; | ||
|
|
||
| -- EXCEPT ALL + EXCEPT | ||
| SELECT udf(k), v FROM tab4 | ||
| EXCEPT ALL | ||
| SELECT k, udf(v) FROM tab3 | ||
| EXCEPT DISTINCT | ||
| SELECT udf(k), udf(v) FROM tab4; | ||
|
|
||
| -- Chain of set operations | ||
| SELECT k, udf(v) FROM tab3 | ||
| EXCEPT ALL | ||
| SELECT udf(k), udf(v) FROM tab4 | ||
| UNION ALL | ||
| SELECT udf(k), v FROM tab3 | ||
| EXCEPT DISTINCT | ||
| SELECT k, udf(v) FROM tab4; | ||
|
|
||
| -- Mismatch on number of columns across both branches | ||
| SELECT k FROM tab3 | ||
| EXCEPT ALL | ||
| SELECT k, v FROM tab4; | ||
|
|
||
| -- Chain of set operations | ||
| SELECT udf(k), udf(v) FROM tab3 | ||
| EXCEPT ALL | ||
| SELECT udf(k), udf(v) FROM tab4 | ||
| UNION | ||
| SELECT udf(k), udf(v) FROM tab3 | ||
| EXCEPT DISTINCT | ||
| SELECT udf(k), udf(v) FROM tab4; | ||
|
|
||
| -- Using MINUS ALL | ||
| SELECT udf(k), udf(v) FROM tab3 | ||
| MINUS ALL | ||
| SELECT k, udf(v) FROM tab4 | ||
| UNION | ||
| SELECT udf(k), udf(v) FROM tab3 | ||
| MINUS DISTINCT | ||
| SELECT k, udf(v) FROM tab4; | ||
|
|
||
| -- Chain of set operations | ||
| SELECT k, udf(v) FROM tab3 | ||
| EXCEPT ALL | ||
| SELECT udf(k), v FROM tab4 | ||
| EXCEPT DISTINCT | ||
| SELECT k, udf(v) FROM tab3 | ||
| EXCEPT DISTINCT | ||
| SELECT udf(k), v FROM tab4; | ||
|
|
||
| -- Join under except all. Should produce empty resultset since both left and right sets | ||
| -- are same. | ||
| SELECT * | ||
| FROM (SELECT tab3.k, | ||
| udf(tab4.v) | ||
| FROM tab3 | ||
| JOIN tab4 | ||
| ON udf(tab3.k) = tab4.k) | ||
| EXCEPT ALL | ||
| SELECT * | ||
| FROM (SELECT udf(tab3.k), | ||
| tab4.v | ||
| FROM tab3 | ||
| JOIN tab4 | ||
| ON tab3.k = udf(tab4.k)); | ||
|
|
||
| -- Join under except all (2) | ||
| SELECT * | ||
| FROM (SELECT udf(udf(tab3.k)), | ||
| udf(tab4.v) | ||
| FROM tab3 | ||
| JOIN tab4 | ||
| ON udf(udf(tab3.k)) = udf(tab4.k)) | ||
| EXCEPT ALL | ||
| SELECT * | ||
| FROM (SELECT udf(tab4.v) AS k, | ||
| udf(udf(tab3.k)) AS v | ||
| FROM tab3 | ||
| JOIN tab4 | ||
| ON udf(tab3.k) = udf(tab4.k)); | ||
|
|
||
| -- Group by under ExceptAll | ||
| SELECT udf(v) FROM tab3 GROUP BY v | ||
| EXCEPT ALL | ||
| SELECT udf(k) FROM tab4 GROUP BY k; | ||
|
|
||
| -- Clean-up | ||
| DROP VIEW IF EXISTS tab1; | ||
| DROP VIEW IF EXISTS tab2; | ||
| DROP VIEW IF EXISTS tab3; | ||
| DROP VIEW IF EXISTS tab4; | ||
Oops, something went wrong.
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.
Is it intentionally to do
udf(6)? Notudf(c1) > 6?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.
Yes, I am trying a different combination of
udfs.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.
Yea, it's kind of a bit random but let's test different cases while we're here..