[feature](fe) Support top-N correlated scalar subqueries - #64254
Draft
morrySnow wants to merge 1 commit into
Draft
[feature](fe) Support top-N correlated scalar subqueries#64254morrySnow wants to merge 1 commit into
morrySnow wants to merge 1 commit into
Conversation
### What problem does this PR solve? Issue Number: None Related PR: apache#64251 Problem Summary: Correlated scalar subqueries with ORDER BY and LIMIT 1 were rejected during analysis. Preserve the top-N shape, rewrite it to ROW_NUMBER partitioned by correlated inner columns and ordered by the subquery sort keys, then filter rank 1. The resulting scalar apply becomes a left outer join so unmatched rows return NULL. ### Release note Support correlated scalar subqueries with ORDER BY and LIMIT 1. ### Check List (For Author) - Test: Unit Test and Regression test - ./run-fe-ut.sh --run org.apache.doris.nereids.rules.analysis.AnalyzeSubQueryTest - ./run-regression-test.sh --run -d query_p0/subquery -s correlated_scalar_subquery - Behavior changed: Yes. Correlated scalar subqueries with ORDER BY and LIMIT 1 are now supported. - Does this need documentation: No
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 28753 ms |
Contributor
TPC-DS: Total hot run time: 169583 ms |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem does this PR solve?
Issue Number: None
Related PR: #64251
Problem Summary: Correlated scalar subqueries with
ORDER BYandLIMIT 1were rejected during analysis. This change preserves the top-N shape and rewrites it toROW_NUMBER, partitioned by the correlated inner columns and ordered by the subquery sort keys, then filters rank 1. The resulting scalar apply becomes a left outer join so unmatched rows returnNULL.Release note
Support correlated scalar subqueries with
ORDER BYandLIMIT 1.Check List (For Author)
./run-fe-ut.sh --run org.apache.doris.nereids.rules.analysis.AnalyzeSubQueryTest./run-fe-ut.sh --run org.apache.doris.nereids.rules.analysis.AnalyzeSubQueryTest#testCorrelatedScalarSubqueryWithTopN./run-regression-test.sh --run -d query_p0/subquery -s correlated_scalar_subqueryORDER BYandLIMIT 1are now supported.