github-actions[bot] commented on code in PR #62304:
URL: https://github.com/apache/doris/pull/62304#discussion_r3212735833
##########
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:
This NULL suffix is also propagated through `map_keys(map_col)` and
`map_values(map_col)`, producing paths like `[map_col, KEYS, NULL]` /
`[map_col, VALUES, NULL]` (the new regression asserts `map_col.KEYS.NULL`). But
the nullness of `map_keys(nullable_map)` or `map_values(nullable_map)` is
determined by the parent map null map, not by the key/value child column. In
BE, `MapFileColumnIterator::set_access_paths()` only switches to
`NULL_MAP_ONLY` when the first sub-path component after the map name is `NULL`;
with `KEYS.NULL`/`VALUES.NULL` it routes the path to the key/value iterator and
still reads offsets plus child data (or relies on scalar fallback). For
`map_keys(map_col) IS NULL` / `IS NOT NULL`, FE should emit/use the parent
`[map_col, NULL]` path, or otherwise add BE handling that treats these
function-level null checks as parent-map null-map-only reads.
--
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]