morrySnow opened a new pull request, #64251:
URL: https://github.com/apache/doris/pull/64251
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
Correlated scalar subqueries with `ORDER BY ... LIMIT 1` were treated like
plain `LIMIT 1` subqueries. Analysis eliminated the root `LogicalLimit`, which
also discarded the TopN semantics instead of rejecting this unsupported
correlated-subquery shape.
This change only eliminates a correlated scalar subquery's `LIMIT 1` when
the limit does not wrap a `LogicalSort`. A TopN remains in the analyzed plan
and is rejected by the existing correlated-subquery validation.
FE unit and regression tests verify that `ORDER BY ... LIMIT 1` is rejected,
while the existing plain `LIMIT 1` coverage continues to verify the supported
path.
### Release note
Reject correlated scalar subqueries containing `ORDER BY` with `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. Unsupported correlated scalar subqueries with TopN
1 now fail analysis.
- 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]