-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28002][SQL] Support WITH clause column aliases #24842
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 4 commits
f772020
f800111
6ae91c5
510eee1
0a00a03
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 |
|---|---|---|
|
|
@@ -24,6 +24,10 @@ SELECT t1.id AS c1, | |
| FROM CTE1 t1 | ||
| CROSS JOIN CTE1 t2; | ||
|
|
||
| -- CTE with column alias | ||
| WITH t(x) AS (SELECT 1) | ||
|
Member
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. Could you add more test cases? For example, can a with clause in a subquery shadow a with clause in an enclosing query with the same name? Another example, use with clauses in a subquery expression?
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. I wanted to focus on column aliases in this PR, but I have another open here which focuses on nested
Member
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. Yep. For the nested |
||
| SELECT * FROM t WHERE x = 1; | ||
|
|
||
| -- Clean up | ||
| DROP VIEW IF EXISTS t; | ||
| DROP VIEW IF EXISTS t2; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 9 | ||
| -- Number of queries: 10 | ||
|
|
||
|
|
||
| -- !query 0 | ||
|
|
@@ -89,16 +89,25 @@ struct<c1:int,c2:int> | |
|
|
||
|
|
||
| -- !query 7 | ||
| DROP VIEW IF EXISTS t | ||
| WITH t(x) AS (SELECT 1) | ||
| SELECT * FROM t WHERE x = 1 | ||
|
Member
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. Almost all the test cases are using one column in the CTE definition. Can you try your best to improve the current test coverage in this new syntax? |
||
| -- !query 7 schema | ||
| struct<> | ||
| struct<x:int> | ||
| -- !query 7 output | ||
|
|
||
| 1 | ||
|
|
||
|
|
||
| -- !query 8 | ||
| DROP VIEW IF EXISTS t2 | ||
| DROP VIEW IF EXISTS t | ||
| -- !query 8 schema | ||
| struct<> | ||
| -- !query 8 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 9 | ||
| DROP VIEW IF EXISTS t2 | ||
| -- !query 9 schema | ||
| struct<> | ||
| -- !query 9 output | ||
|
|
||
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.
Duplicate names within a single CTE definition are not allowed.