morrySnow opened a new pull request, #64254:
URL: https://github.com/apache/doris/pull/64254
### What problem does this PR solve?
Issue Number: None
Related PR: #64251
Problem Summary: Correlated scalar subqueries with `ORDER BY` and `LIMIT 1`
were rejected during analysis. This change preserves the top-N shape and
rewrites it to `ROW_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 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-fe-ut.sh --run
org.apache.doris.nereids.rules.analysis.AnalyzeSubQueryTest#testCorrelatedScalarSubqueryWithTopN`
- `./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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]