-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18814][SQL] CheckAnalysis rejects TPCDS query 32 #16246
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
34 commits
Select commit
Hold shift + click to select a range
b988651
[SPARK-16804][SQL] Correlated subqueries containing LIMIT return inco…
nsyca 069ed8f
[SPARK-16804][SQL] Correlated subqueries containing LIMIT return inco…
nsyca edca333
New positive test cases
nsyca 64184fd
Fix unit test case failure
nsyca 29f82b0
blocking TABLESAMPLE
nsyca ac43ab4
Fixing code styling
nsyca 631d396
Correcting Scala test style
nsyca 7eb9b2d
One (last) attempt to correct the Scala style tests
nsyca 1387cf5
Merge remote-tracking branch 'upstream/master'
nsyca 6d9bade
Merge remote-tracking branch 'upstream/master'
nsyca 9a1f80b
Merge remote-tracking branch 'upstream/master'
nsyca 3fe9429
Merge remote-tracking branch 'upstream/master'
nsyca 0757b81
Merge remote-tracking branch 'upstream/master'
nsyca 35b77f0
Merge remote-tracking branch 'upstream/master'
nsyca c63b8c6
Merge remote-tracking branch 'upstream/master'
nsyca f3351d5
Merge remote-tracking branch 'upstream/master'
nsyca 9fc5c33
Merge remote-tracking branch 'upstream/master'
nsyca 402e1d9
Merge remote-tracking branch 'upstream/master'
nsyca b117281
Merge remote-tracking branch 'upstream/master'
nsyca 3023399
Merge remote-tracking branch 'upstream/master'
nsyca 4b692f0
Merge remote-tracking branch 'upstream/master'
nsyca c8aadb5
Merge remote-tracking branch 'upstream/master'
nsyca 2181647
Merge remote-tracking branch 'upstream/master'
nsyca c8588de
Merge remote-tracking branch 'upstream/master'
nsyca 0d823d5
Merge remote-tracking branch 'upstream/master'
nsyca bc27b4e
Merge remote-tracking branch 'upstream/master'
nsyca e871783
first pass
nsyca b93b3ce
second pass
nsyca 09b543b
address @gatorsmile's comments
nsyca f88a205
Address @gatorsmile's 2nd round comments
nsyca ca1dc96
Address @gatorsmile's 3rd round comments
nsyca 724335a
Address @gatorsmile's 3rd round comments(2)
nsyca 6040dcf
Code the fix based on @hvanhovell's solution
nsyca 0b6bfd4
Address @hvanhovell's 2nd comments
nsyca 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
20 changes: 20 additions & 0 deletions
20
sql/core/src/test/resources/sql-tests/inputs/scalar-subquery.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,20 @@ | ||
| CREATE OR REPLACE TEMPORARY VIEW p AS VALUES (1, 1) AS T(pk, pv); | ||
| CREATE OR REPLACE TEMPORARY VIEW c AS VALUES (1, 1) AS T(ck, cv); | ||
|
|
||
| -- SPARK-18814.1: Simplified version of TPCDS-Q32 | ||
| SELECT pk, cv | ||
| FROM p, c | ||
| WHERE p.pk = c.ck | ||
| AND c.cv = (SELECT avg(c1.cv) | ||
| FROM c c1 | ||
| WHERE c1.ck = p.pk); | ||
|
|
||
| -- SPARK-18814.2: Adding stack of aggregates | ||
| SELECT pk, cv | ||
| FROM p, c | ||
| WHERE p.pk = c.ck | ||
| AND c.cv = (SELECT max(avg) | ||
| FROM (SELECT c1.cv, avg(c1.cv) avg | ||
| FROM c c1 | ||
| WHERE c1.ck = p.pk | ||
| GROUP BY c1.cv)); | ||
46 changes: 46 additions & 0 deletions
46
sql/core/src/test/resources/sql-tests/results/scalar-subquery.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,46 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 4 | ||
|
|
||
|
|
||
| -- !query 0 | ||
| CREATE OR REPLACE TEMPORARY VIEW p AS VALUES (1, 1) AS T(pk, pv) | ||
| -- !query 0 schema | ||
| struct<> | ||
| -- !query 0 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 1 | ||
| CREATE OR REPLACE TEMPORARY VIEW c AS VALUES (1, 1) AS T(ck, cv) | ||
| -- !query 1 schema | ||
| struct<> | ||
| -- !query 1 output | ||
|
|
||
|
|
||
|
|
||
| -- !query 2 | ||
| SELECT pk, cv | ||
| FROM p, c | ||
| WHERE p.pk = c.ck | ||
| AND c.cv = (SELECT avg(c1.cv) | ||
| FROM c c1 | ||
| WHERE c1.ck = p.pk) | ||
| -- !query 2 schema | ||
| struct<pk:int,cv:int> | ||
| -- !query 2 output | ||
| 1 1 | ||
|
|
||
|
|
||
| -- !query 3 | ||
| SELECT pk, cv | ||
| FROM p, c | ||
| WHERE p.pk = c.ck | ||
| AND c.cv = (SELECT max(avg) | ||
| FROM (SELECT c1.cv, avg(c1.cv) avg | ||
| FROM c c1 | ||
| WHERE c1.ck = p.pk | ||
| GROUP BY c1.cv)) | ||
| -- !query 3 schema | ||
| struct<pk:int,cv:int> | ||
| -- !query 3 output | ||
| 1 1 |
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
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.
I have a question that is not related to this JIRA. In the above query, if we do not have the
GROUP BY c1.cv, it still works. It sounds like the subquery progressing ignores group by clauses. What is the reason?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.
Nice catch! I think this is a bug. There could be multiple values of c1.cv. Without a GROUP BY clause, which value does it return? Could you please open a JIRA to track this? I will investigate along with my subquery work. Do you think this is a blocker?
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.
It is not a blocker. We are probably missing this case in
CheckAnalysis. This currently works because it gets eliminated during optimization (the optimizer prunes the unused output). @nsyca it would be great if you can take a look at it, could you also create a separate JIRA to track this?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.
I opened SPARK-18863 to track this problem.
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.
Thank you confirming this is a bug. I expect I can get the error message like
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.
Or in some other cases, we should see the error message like
Both error handling are missing.