englefly commented on code in PR #64436:
URL: https://github.com/apache/doris/pull/64436#discussion_r3421352791


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -618,6 +618,39 @@ private Void collectArrayPathInLambda(Lambda lambda, 
CollectorContext context) {
         } finally {
             nameToLambdaArguments.pop();
         }
+
+        // After visiting the lambda body, for any bound array whose lambda 
variable
+        // was NOT referenced in the body (e.g. x -> true where x never 
appears),
+        // visitArrayItemSlot was never called and the array column's access 
path is
+        // missing. This gap is exposed when an is-null or offset-only path 
has been
+        // registered for the same slot — NestedColumnPruning then incorrectly 
prunes
+        // the complex column to null-only / offset-only instead of reading 
full data.
+        //
+        // Detect usage by scanning the lambda body for ArrayItemSlots 
matching the
+        // argument name, which is more reliable than getInputSlots() that 
deliberately
+        // excludes ArrayItemSlot and may falsely match outer slots.
+        //
+        // Must use a fresh context: when the body DOES reference some 
variables
+        // (e.g. (x,y) -> x > 0), visitArrayItemSlot mutates 
context.accessPathBuilder
+        // in-place (addPrefix without cleanup). A fresh context isolates the 
fallback
+        // path for unreferenced variables from pollution by referenced ones.
+        for (Expression argument : arguments) {
+            if (argument instanceof ArrayItemReference) {
+                String argName = ((ArrayItemReference) argument).getName();
+                boolean isReferenced = arguments.get(0)
+                        .<ArrayItemSlot>collect(e -> e instanceof 
ArrayItemSlot)
+                        .stream()
+                        .anyMatch(slot -> slot.getName().equals(argName));

Review Comment:
   done



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