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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -98,21 +102,47 @@ public void collect(Expression expression) {
         expression.accept(this, new CollectorContext(statementContext, 
bottomPredicate));
     }
 
+    public void collectWholeVariantExpression(Expression expression) {
+        CollectorContext context = new CollectorContext(statementContext, 
bottomPredicate);
+        context.setCollectVariantRoot(true);
+        expression.accept(this, context);
+    }
+
     private Void continueCollectAccessPath(Expression expr, CollectorContext 
context) {
         return expr.accept(this, context);
     }
 
+    private void recordVariantRootAccessPath(SlotReference slotReference, 
CollectorContext context) {
+        int slotId = slotReference.getExprId().asInt();
+        slotToAccessPaths.put(slotId,
+                new CollectAccessPathResult(
+                        ImmutableList.of(slotReference.getName()),
+                        context.bottomFilter, ColumnAccessPathType.DATA));
+    }
+
     @Override
     public Void visit(Expression expr, CollectorContext context) {
         for (Expression child : expr.children()) {
-            child.accept(this, new CollectorContext(context.statementContext, 
context.bottomFilter));
+            if (child.getDataType().isVariantType()
+                    && (context.collectVariantRoot

Review Comment:
   The generic visitor still does not force a root read for comparison 
predicates that consume a whole VARIANT but return BOOLEAN. For example, `WHERE 
v = cast('{"k":1,"other":2}' AS VARIANT) AND v['k'] IS NOT NULL` visits the 
`EqualTo` with an empty context; because the predicate result is BOOLEAN, this 
branch sends `v` through a fresh empty context and records no root `[v]` 
demand. The sibling nested predicate can then leave only `[v, k]` at the scan, 
so the equality is evaluated against a truncated VARIANT and can reject a 
matching row or accept a row that only matches the selected subpath. Please 
make whole-VARIANT-consuming comparison predicates force a root access and add 
coverage combining VARIANT equality/comparison with a sibling nested VARIANT 
predicate. This is distinct from the existing `variant_type` thread because 
comparison predicates are not handled by the new `GetVariantType` override and 
still fall through this default visitor.



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