-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28279][SQL][PYTHON][TESTS] Convert and port 'group-analytics.sql' into UDF test base #25196
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
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
64 changes: 64 additions & 0 deletions
64
sql/core/src/test/resources/sql-tests/inputs/udf/udf-group-analytics.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,64 @@ | ||
| -- This test file was converted from group-analytics.sql. | ||
| -- TODO: UDF should be inserted and tested at GROUP BY clause after SPARK-28445 | ||
| CREATE OR REPLACE TEMPORARY VIEW testData AS SELECT * FROM VALUES | ||
HyukjinKwon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2) | ||
| AS testData(a, b); | ||
|
|
||
| -- CUBE on overlapping columns | ||
| SELECT a + b, b, udf(SUM(a - b)) FROM testData GROUP BY a + b, b WITH CUBE; | ||
|
|
||
| SELECT a, udf(b), SUM(b) FROM testData GROUP BY a, b WITH CUBE; | ||
|
|
||
| -- ROLLUP on overlapping columns | ||
| SELECT udf(a + b), b, SUM(a - b) FROM testData GROUP BY a + b, b WITH ROLLUP; | ||
|
|
||
| SELECT a, b, udf(SUM(b)) FROM testData GROUP BY a, b WITH ROLLUP; | ||
|
|
||
| CREATE OR REPLACE TEMPORARY VIEW courseSales AS SELECT * FROM VALUES | ||
| ("dotNET", 2012, 10000), ("Java", 2012, 20000), ("dotNET", 2012, 5000), ("dotNET", 2013, 48000), ("Java", 2013, 30000) | ||
| AS courseSales(course, year, earnings); | ||
|
|
||
| -- ROLLUP | ||
| SELECT course, year, SUM(earnings) FROM courseSales GROUP BY ROLLUP(course, year) ORDER BY udf(course), year; | ||
|
|
||
| -- CUBE | ||
| SELECT course, year, SUM(earnings) FROM courseSales GROUP BY CUBE(course, year) ORDER BY course, udf(year); | ||
|
|
||
| -- GROUPING SETS | ||
| SELECT course, udf(year), SUM(earnings) FROM courseSales GROUP BY course, year GROUPING SETS(course, year); | ||
| SELECT course, year, udf(SUM(earnings)) FROM courseSales GROUP BY course, year GROUPING SETS(course); | ||
| SELECT udf(course), year, SUM(earnings) FROM courseSales GROUP BY course, year GROUPING SETS(year); | ||
|
|
||
| -- GROUPING SETS with aggregate functions containing groupBy columns | ||
| SELECT course, udf(SUM(earnings)) AS sum FROM courseSales | ||
| GROUP BY course, earnings GROUPING SETS((), (course), (course, earnings)) ORDER BY course, udf(sum); | ||
| SELECT course, SUM(earnings) AS sum, GROUPING_ID(course, earnings) FROM courseSales | ||
| GROUP BY course, earnings GROUPING SETS((), (course), (course, earnings)) ORDER BY udf(course), sum; | ||
|
|
||
| -- GROUPING/GROUPING_ID | ||
| SELECT udf(course), udf(year), GROUPING(course), GROUPING(year), GROUPING_ID(course, year) FROM courseSales | ||
| GROUP BY CUBE(course, year); | ||
| SELECT course, udf(year), GROUPING(course) FROM courseSales GROUP BY course, year; | ||
| SELECT course, udf(year), GROUPING_ID(course, year) FROM courseSales GROUP BY course, year; | ||
| SELECT course, year, grouping__id FROM courseSales GROUP BY CUBE(course, year) ORDER BY grouping__id, course, udf(year); | ||
|
|
||
| -- GROUPING/GROUPING_ID in having clause | ||
| SELECT course, year FROM courseSales GROUP BY CUBE(course, year) | ||
| HAVING GROUPING(year) = 1 AND GROUPING_ID(course, year) > 0 ORDER BY course, udf(year); | ||
| SELECT course, udf(year) FROM courseSales GROUP BY course, year HAVING GROUPING(course) > 0; | ||
| SELECT course, udf(udf(year)) FROM courseSales GROUP BY course, year HAVING GROUPING_ID(course) > 0; | ||
| SELECT udf(course), year FROM courseSales GROUP BY CUBE(course, year) HAVING grouping__id > 0; | ||
|
|
||
| -- GROUPING/GROUPING_ID in orderBy clause | ||
| SELECT course, year, GROUPING(course), GROUPING(year) FROM courseSales GROUP BY CUBE(course, year) | ||
| ORDER BY GROUPING(course), GROUPING(year), course, udf(year); | ||
| SELECT course, year, GROUPING_ID(course, year) FROM courseSales GROUP BY CUBE(course, year) | ||
| ORDER BY GROUPING(course), GROUPING(year), course, udf(year); | ||
| SELECT course, udf(year) FROM courseSales GROUP BY course, udf(year) ORDER BY GROUPING(course); | ||
| SELECT course, udf(year) FROM courseSales GROUP BY course, udf(year) ORDER BY GROUPING_ID(course); | ||
| SELECT course, year FROM courseSales GROUP BY CUBE(course, year) ORDER BY grouping__id, udf(course), year; | ||
|
|
||
| -- Aliases in SELECT could be used in ROLLUP/CUBE/GROUPING SETS | ||
| SELECT udf(a + b) AS k1, udf(b) AS k2, SUM(a - b) FROM testData GROUP BY CUBE(k1, k2); | ||
| SELECT udf(udf(a + b)) AS k, b, SUM(a - b) FROM testData GROUP BY ROLLUP(k, b); | ||
| SELECT udf(a + b), udf(udf(b)) AS k, SUM(a - b) FROM testData GROUP BY a + b, k GROUPING SETS(k) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.