-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35070][SQL] TRANSFORM not support alias in inputs #32165
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,7 +206,7 @@ FROM script_trans | |
| LIMIT 1; | ||
|
|
||
| SELECT TRANSFORM( | ||
| b AS d5, a, | ||
|
Contributor
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. what was the behavior before (Spark 3.1 or older) when there is an alias? do we just ignore the alias?
Contributor
Author
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.
Treat it just like select clause since
Contributor
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. Can we add an item in the migration guide? Mentioning that alias is not allowed anymore in
Contributor
Author
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.
Done |
||
| b, a, | ||
| CASE | ||
| WHEN c > 100 THEN 1 | ||
| WHEN c < 100 THEN 2 | ||
|
|
@@ -225,45 +225,45 @@ SELECT TRANSFORM(*) | |
| FROM script_trans | ||
| WHERE a <= 4; | ||
|
|
||
| SELECT TRANSFORM(b AS d, MAX(a) as max_a, CAST(SUM(c) AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a), CAST(SUM(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 4 | ||
| GROUP BY b; | ||
|
|
||
| SELECT TRANSFORM(b AS d, MAX(a) FILTER (WHERE a > 3) AS max_a, CAST(SUM(c) AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a) FILTER (WHERE a > 3), CAST(SUM(c) AS STRING)) | ||
| USING 'cat' AS (a,b,c) | ||
| FROM script_trans | ||
| WHERE a <= 4 | ||
| GROUP BY b; | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) as max_a, CAST(sum(c) AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a), CAST(sum(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 2 | ||
| GROUP BY b; | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) as max_a, CAST(SUM(c) AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a), CAST(SUM(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 4 | ||
| GROUP BY b | ||
| HAVING max_a > 0; | ||
| HAVING MAX(a) > 0; | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) as max_a, CAST(SUM(c) AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a), CAST(SUM(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 4 | ||
| GROUP BY b | ||
| HAVING max(a) > 1; | ||
| HAVING MAX(a) > 1; | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) OVER w as max_a, CAST(SUM(c) OVER w AS STRING)) | ||
| SELECT TRANSFORM(b, MAX(a) OVER w, CAST(SUM(c) OVER w AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 4 | ||
| WINDOW w AS (PARTITION BY b ORDER BY a); | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) as max_a, CAST(SUM(c) AS STRING), myCol, myCol2) | ||
| SELECT TRANSFORM(b, MAX(a), CAST(SUM(c) AS STRING), myCol, myCol2) | ||
| USING 'cat' AS (a, b, c, d, e) | ||
| FROM script_trans | ||
| LATERAL VIEW explode(array(array(1,2,3))) myTable AS myCol | ||
|
|
@@ -280,7 +280,7 @@ FROM( | |
| SELECT a + 1; | ||
|
|
||
| FROM( | ||
| SELECT TRANSFORM(a, SUM(b) b) | ||
| SELECT TRANSFORM(a, SUM(b)) | ||
| USING 'cat' AS (`a` INT, b STRING) | ||
| FROM script_trans | ||
| GROUP BY a | ||
|
|
@@ -308,14 +308,6 @@ HAVING true; | |
|
|
||
| SET spark.sql.legacy.parser.havingWithoutGroupByAsWhere=false; | ||
|
|
||
| SET spark.sql.parser.quotedRegexColumnNames=true; | ||
|
|
||
| SELECT TRANSFORM(`(a|b)?+.+`) | ||
| USING 'cat' AS (c) | ||
| FROM script_trans; | ||
|
|
||
| SET spark.sql.parser.quotedRegexColumnNames=false; | ||
|
|
||
| -- SPARK-34634: self join using CTE contains transform | ||
| WITH temp AS ( | ||
| SELECT TRANSFORM(a) USING 'cat' AS (b string) FROM t | ||
|
|
@@ -331,3 +323,22 @@ SELECT TRANSFORM(ALL b, a, c) | |
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 4; | ||
|
|
||
| -- SPARK-35070: TRANSFORM not support alias in inputs | ||
| SELECT TRANSFORM(b AS b_1, MAX(a), CAST(sum(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 2 | ||
| GROUP BY b; | ||
|
|
||
| SELECT TRANSFORM(b b_1, MAX(a), CAST(sum(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 2 | ||
| GROUP BY b; | ||
|
|
||
| SELECT TRANSFORM(b, MAX(a) AS max_a, CAST(sum(c) AS STRING)) | ||
| USING 'cat' AS (a, b, c) | ||
| FROM script_trans | ||
| WHERE a <= 2 | ||
| GROUP BY b; | ||
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 there any valid use case around it? Can users access
c1, c2somehow? e.g.SELECT c1 FROM (SELECT TRANSFORM ...)Uh oh!
There was an error while loading. Please reload this page.
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.
Such as
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.
this looks super weird and not SQL-ish.