-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28287][SQL][PYTHON][TESTS] Convert and port 'udaf.sql' into UDF test base #25194
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
18 changes: 18 additions & 0 deletions
18
sql/core/src/test/resources/sql-tests/inputs/udf/udf-udaf.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,18 @@ | ||
| -- This test file was converted from udaf.sql. | ||
|
|
||
| CREATE OR REPLACE TEMPORARY VIEW t1 AS SELECT * FROM VALUES | ||
| (1), (2), (3), (4) | ||
| as t1(int_col1); | ||
|
|
||
| CREATE FUNCTION myDoubleAvg AS 'test.org.apache.spark.sql.MyDoubleAvg'; | ||
|
|
||
| SELECT default.myDoubleAvg(udf(int_col1)) as my_avg, udf(default.myDoubleAvg(udf(int_col1))) as my_avg2, udf(default.myDoubleAvg(int_col1)) as my_avg3 from t1; | ||
|
|
||
| SELECT default.myDoubleAvg(udf(int_col1), udf(3)) as my_avg from t1; | ||
|
|
||
| CREATE FUNCTION udaf1 AS 'test.non.existent.udaf'; | ||
|
|
||
| SELECT default.udaf1(udf(int_col1)) as udaf1, udf(default.udaf1(udf(int_col1))) as udaf2, udf(default.udaf1(int_col1)) as udaf3 from t1; | ||
|
|
||
| DROP FUNCTION myDoubleAvg; | ||
| DROP FUNCTION udaf1; | ||
72 changes: 72 additions & 0 deletions
72
sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out
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,72 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 8 | ||
|
|
||
|
|
||
| -- !query 0 | ||
| -- This test file was converted from udaf.sql. | ||
|
|
||
| CREATE OR REPLACE TEMPORARY VIEW t1 AS SELECT * FROM VALUES | ||
| (1), (2), (3), (4) | ||
| as t1(int_col1) | ||
| -- !query 0 schema | ||
| struct<> | ||
| -- !query 0 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 1 | ||
| CREATE FUNCTION myDoubleAvg AS 'test.org.apache.spark.sql.MyDoubleAvg' | ||
| -- !query 1 schema | ||
| struct<> | ||
| -- !query 1 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 2 | ||
| SELECT default.myDoubleAvg(udf(int_col1)) as my_avg, udf(default.myDoubleAvg(udf(int_col1))) as my_avg2, udf(default.myDoubleAvg(int_col1)) as my_avg3 from t1 | ||
| -- !query 2 schema | ||
| struct<my_avg:double,my_avg2:double,my_avg3:double> | ||
| -- !query 2 output | ||
| 102.5 102.5 102.5 | ||
|
|
||
|
|
||
| -- !query 3 | ||
| SELECT default.myDoubleAvg(udf(int_col1), udf(3)) as my_avg from t1 | ||
| -- !query 3 schema | ||
| struct<> | ||
| -- !query 3 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Invalid number of arguments for function default.myDoubleAvg. Expected: 1; Found: 2; line 1 pos 7 | ||
|
|
||
|
|
||
| -- !query 4 | ||
| CREATE FUNCTION udaf1 AS 'test.non.existent.udaf' | ||
| -- !query 4 schema | ||
| struct<> | ||
| -- !query 4 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 5 | ||
| SELECT default.udaf1(udf(int_col1)) as udaf1, udf(default.udaf1(udf(int_col1))) as udaf2, udf(default.udaf1(int_col1)) as udaf3 from t1 | ||
| -- !query 5 schema | ||
| struct<> | ||
| -- !query 5 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Can not load class 'test.non.existent.udaf' when registering the function 'default.udaf1', please make sure it is on the classpath; line 1 pos 94 | ||
|
|
||
|
|
||
| -- !query 6 | ||
| DROP FUNCTION myDoubleAvg | ||
| -- !query 6 schema | ||
| struct<> | ||
| -- !query 6 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 7 | ||
| DROP FUNCTION udaf1 | ||
| -- !query 7 schema | ||
| struct<> | ||
| -- !query 7 output | ||
|
|
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.
nit: this indent seems wrong? although the indent doesn't matter here..