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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -506,14 +546,35 @@ public Void visitArraySortBy(ArraySortBy arraySortBy, 
CollectorContext context)
         return visit(arraySortBy, context);
     }
 
-    // @Override
-    // public Void visitIsNull(IsNull isNull, CollectorContext context) {
-    //     if (context.accessPathBuilder.isEmpty()) {
-    //         context.setType(ColumnAccessPathType.META);
-    //         return continueCollectAccessPath(isNull.child(), context);
-    //     }
-    //     return visit(isNull, context);
-    // }
+    @Override
+    public Void visitIsNull(IsNull isNull, CollectorContext context) {
+        Expression arg = isNull.child();
+        // Skip variant sub-column paths (v['k'] IS NULL): the sub-column path 
is already baked
+        // into the SlotReference, so null-only access doesn't apply the same 
way.
+        if (arg instanceof SlotReference && ((SlotReference) 
arg).hasSubColPath()) {
+            return visit(isNull, context);
+        }
+        // Optimize IS NULL on nullable expressions: create a context with 
NULL suffix to indicate
+        // only the null flag is needed. Works for top-level columns (col IS 
NULL → [col, NULL])
+        // and nested access (struct_element(s, 'city') IS NULL → [s, city, 
NULL]).
+        // For unrecognized expressions, the default visitor resets context, 
safely discarding NULL.
+        if (arg.nullable() && context.accessPathBuilder.isEmpty()) {
+            CollectorContext nullContext =
+                    new CollectorContext(context.statementContext, 
context.bottomFilter);
+            
nullContext.accessPathBuilder.addSuffix(AccessPathInfo.ACCESS_NULL);
+            return continueCollectAccessPath(arg, nullContext);

Review Comment:
   fixed



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