github-actions[bot] commented on code in PR #64247:
URL: https://github.com/apache/doris/pull/64247#discussion_r3374186953


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SubExprAnalyzer.java:
##########
@@ -139,6 +139,10 @@ public Expression visitScalarSubquery(ScalarSubquery 
scalar, T context) {
         if (isCorrelated) {
             if (analyzedSubqueryPlan instanceof LogicalLimit) {
                 LogicalLimit limit = (LogicalLimit) analyzedSubqueryPlan;
+                if (limit.child() instanceof LogicalSort) {

Review Comment:
   This only rejects `LIMIT` directly over `SORT`, but Nereids also has the 
`limit -> project -> sort` shape (see `LimitSortToTopN` lines 48-58). A 
correlated scalar such as `select ... where t1.c2 > (select c2 from t2 where 
t1.c1 = t2.c1 order by c1 limit 1)` can be analyzed as 
`LogicalLimit(LogicalProject(LogicalSort(...)))`: this check is skipped, 
`limitOneIsEliminated` is set, and the later `any_value` aggregate can still 
ignore the requested ordering. Please reject the project-between-limit-and-sort 
shape as well, and add a regression case where the selected expression differs 
from the order key.



-- 
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]

Reply via email to