hello-stephen commented on code in PR #71318:
URL: https://github.com/apache/doris/pull/71318#discussion_r4780525515


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CollectFilterAboveConsumer.java:
##########
@@ -42,7 +43,7 @@ public Rule build() {
                     continue;
                 }
                 Expression rewrittenExpr = expr.rewriteUp(e -> {
-                    if (e instanceof Slot) {
+                    if (e instanceof Slot && !(e instanceof 
SlotNotFromChildren)) {

Review Comment:
   [P3] Match producer predicates using their plan input slots
   
   Consider a materialized CTE over a scan with these consumer branches:
   
   ```text
   CrossJoin
     Filter(array_contains(array_map(x#1 -> trim(x#1), arr#L), 'a'))
       CTEConsumer(arr#L)
     Filter(array_contains(array_map(y#2 -> trim(y#2), arr#R), 'b'))
       CTEConsumer(arr#R)
   ```
   
   The collector correctly maps both array inputs to `arr#P` and preserves the 
lambda bindings. But `RewriteCteChildren.tryToConstructFilter` compares raw 
`SlotReference` sets, so `{arr#P, x#1}` and `{arr#P, y#2}` fail to match. The 
producer gets no disjunction and can materialize every row before the consumers 
apply their filters. Use `Expression.getInputSlots()` for the matching key and 
add a plan assertion with a lambda filter on each consumer.



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