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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java:
##########
@@ -205,8 +237,18 @@ private boolean checkFilter(LogicalFilter<? extends Plan> 
outerFilter) {
             while (outerIterator.hasNext()) {
                 Expression outerExpr = outerIterator.next();
                 if (ExpressionIdenticalChecker.INSTANCE.check(innerExpr, 
outerExpr)) {
+                    // Volatile and NoneMovableFunction predicates must never
+                    // be matched as inner-filter conjuncts: two syntactically
+                    // identical calls are independent evaluations.
+                    if (isVolatileOrNoneMovable(innerExpr)
+                            || isVolatileOrNoneMovable(outerExpr)) {
+                        continue;
+                    }
                     innerIterator.remove();

Review Comment:
   After matching one inner conjunct, this loop needs to stop scanning the 
remaining outer conjuncts. Right now it removes the current `innerIterator` 
entry but keeps iterating `outerConjunctSet`, so this accepted shape can match 
the same replaced inner predicate twice:
   
   ```text
   Filter(f.k = d.k, d.k = f.k, f.v * 2 > sum_alias)
     Apply(correlation: d.k)
       CrossJoin(Scan fact f, Scan dim_unique d)
       Aggregate(sum(f2.v) AS sum_alias)
         Filter(f2.k = d.k)
           Scan fact f2
   ```
   
   After slot replacement, the inner predicate becomes `f.k = d.k`. 
`visitComparisonPredicate()` accepts both the direct form and `cp.commute()`, 
while the two outer expressions are distinct because normal expression equality 
is child-order-sensitive. The second match calls `innerIterator.remove()` again 
without another `next()`, which throws `IllegalStateException` during planning. 
Please break/continue to the next inner predicate after a successful match, and 
add a regression with both ordered forms in the outer filter.



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