-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-50091][SQL] Handle case of aggregates in left-hand operand of IN-subquery #48627
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 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
79b5089
Some testing
bersprockets 7fe2a08
update
bersprockets c96af36
Small cleanup
bersprockets 424d803
Update
bersprockets 2b1a376
Add catalyst test
bersprockets 9c443b0
Fix names
bersprockets 46d43fd
Clean up some comments
bersprockets ca4dba8
Cleanup
bersprockets e0fc82f
Rename tests
bersprockets 3e52a12
Update
bersprockets 1db5316
Review updates
bersprockets f6aa964
Comment update
bersprockets cc6384b
Address review comments
bersprockets 93d98e7
Move unary node handler to its own utility method
bersprockets cb4066a
Respond to review comments
bersprockets b5ee466
Make test more explicit
bersprockets 0e1c170
Test updates
bersprockets 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
Review updates
- Loading branch information
commit 1db531606ba23732efa69747881487ca3ab39d25
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -266,55 +266,191 @@ object RewritePredicateSubquery extends Rule[LogicalPlan] with PredicateHelper { | |||||
| condition = Some(newCondition))) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Handle the case where the left-hand side of an IN-subquery contains an aggregate. | ||||||
| // | ||||||
| // This handler pulls up any expression containing such an IN-subquery into a new Project | ||||||
| // node and then re-enters RewritePredicateSubquery#apply, where the new Project node | ||||||
| // will be handled by the Unary node handler. The Unary node handler will transform the | ||||||
| // plan into a join. Without this pre-transformation, the Unary node handler would | ||||||
| // create a join with an aggregate expression in the join condition, which is illegal | ||||||
| // (see SPARK-50091). | ||||||
| // | ||||||
| // For example: | ||||||
| // | ||||||
| // SELECT col1, SUM(col2) IN (SELECT c2 FROM v1) as x | ||||||
| // FROM v2 GROUP BY col1; | ||||||
| // | ||||||
| // The above query has this plan on entry to RewritePredicateSubquery#apply: | ||||||
| // | ||||||
| // Aggregate [col1#28], [col1#28, sum(col2#29) IN (list#24 []) AS x#25] | ||||||
| // : +- LocalRelation [c2#35L] | ||||||
| // +- LocalRelation [col1#28, col2#29] | ||||||
| // | ||||||
| // Note that the Aggregate node contains the IN-subquery and the left-hand | ||||||
| // side of the IN-subquery is an aggregate expression (sum(col2#28)). | ||||||
|
||||||
| // side of the IN-subquery is an aggregate expression (sum(col2#28)). | |
| // side of the IN-subquery is an aggregate expression (sum(col2#29)). |
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.