-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-16771][SQL] WITH clause should not fall into infinite loop. #14397
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
64b81fc
[SPARK-16771][SQL] WITH clause should not fall into infinite loop.
dongjoon-hyun 788e136
Address comments.
dongjoon-hyun fd27b04
WITH clause should be removed.
dongjoon-hyun ba45b1b
Remove testcase removed from master.
dongjoon-hyun 7f74ec7
Move testcase into `sql-tests`
dongjoon-hyun f1f4a83
Rename files.
dongjoon-hyun 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
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
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
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
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
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,14 @@ | ||
| create temporary view t as select * from values 0, 1, 2 as t(id); | ||
| create temporary view t2 as select * from values 0, 1 as t(id); | ||
|
|
||
| -- WITH clause should not fall into infinite loop by referencing self | ||
| WITH s AS (SELECT 1 FROM s) SELECT * FROM s; | ||
|
|
||
| -- WITH clause should reference the base table | ||
| WITH t AS (SELECT 1 FROM t) SELECT * FROM t; | ||
|
|
||
| -- WITH clause should not allow cross reference | ||
| WITH s1 AS (SELECT 1 FROM s2), s2 AS (SELECT 1 FROM s1) SELECT * FROM s1, s2; | ||
|
|
||
| -- WITH clause should reference the previous CTE | ||
| WITH t1 AS (SELECT * FROM t2), t2 AS (SELECT 2 FROM t1) SELECT * FROM t1, t2; |
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,57 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 6 | ||
|
|
||
|
|
||
| -- !query 0 | ||
| create temporary view t as select * from values 0, 1, 2 as t(id) | ||
| -- !query 0 schema | ||
| struct<> | ||
| -- !query 0 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 1 | ||
| create temporary view t2 as select * from values 0, 1 as t(id) | ||
| -- !query 1 schema | ||
| struct<> | ||
| -- !query 1 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 2 | ||
| WITH s AS (SELECT 1 FROM s) SELECT * FROM s | ||
| -- !query 2 schema | ||
| struct<> | ||
| -- !query 2 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Table or view not found: s; line 1 pos 25 | ||
|
|
||
|
|
||
| -- !query 3 | ||
| WITH t AS (SELECT 1 FROM t) SELECT * FROM t | ||
| -- !query 3 schema | ||
| struct<1:int> | ||
| -- !query 3 output | ||
| 1 | ||
| 1 | ||
| 1 | ||
|
|
||
|
|
||
| -- !query 4 | ||
| WITH s1 AS (SELECT 1 FROM s2), s2 AS (SELECT 1 FROM s1) SELECT * FROM s1, s2 | ||
| -- !query 4 schema | ||
| struct<> | ||
| -- !query 4 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Table or view not found: s2; line 1 pos 26 | ||
|
|
||
|
|
||
| -- !query 5 | ||
| WITH t1 AS (SELECT * FROM t2), t2 AS (SELECT 2 FROM t1) SELECT * FROM t1, t2 | ||
| -- !query 5 schema | ||
| struct<id:int,2:int> | ||
| -- !query 5 output | ||
| 0 2 | ||
| 0 2 | ||
| 1 2 | ||
| 1 2 |
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.
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.
Perhaps document that the CTEs should be ordered in the way that they are defined.
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.
Yep. I'll add that clearly.