forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-46526][SQL] Support LIMIT over correlated subqueries where pre…
…dicates only reference outer table ### What changes were proposed in this pull request? The type of query that this PR addresses is the following: ``` SELECT COUNT(DISTINCT(t1a)) FROM t1 WHERE t1d IN (SELECT t2d FROM t2 WHERE t1a IS NOT NULL LIMIT 10); ``` Here, the predicate in the subquery `t1a IS NOT NULL` does not reference the inner table at all, so our standard decorrelation technique of "compute 10 values of t2d per every value of the inner table" does not work. In fact, such predicates can be lifted above the limit 10. This PR achieves exactly that. ### Why are the changes needed? Fixed the bug. ### Does this PR introduce _any_ user-facing change? Some broken queries are now working. ### How was this patch tested? Query tests. ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#44514 from agubichev/SPARK-46526_limit_corr. Authored-by: Andrey Gubichev <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
- Loading branch information
Showing
10 changed files
with
431 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.