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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -98,21 +98,46 @@ 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()

Review Comment:
   Propagating the caller's `accessPathBuilder` into every VARIANT child is 
only safe when that child is the same object being accessed. For expressions 
that construct or extract another container, the prefix can belong to that 
container rather than to the VARIANT slot. For example, `SELECT 
struct_element(named_struct('a', v), 'a')['k'] FROM t` reaches 
`visitElementAt()` with suffix `k`, `visitStructElement()` prefixes `a`, and 
then this generic visitor sends `[a, k]` into the `named_struct` child `v`, 
recording `[v, a, k]` instead of `[v, k]`. The scan can then prune away the 
real `k` subfield and return NULL/missing data (especially when combined with 
another predicate that keeps pruning enabled). Please only propagate the 
builder through expressions that preserve VARIANT path semantics, or add 
explicit handling for constructor/extractor expressions that rewrites the path 
before visiting VARIANT children, with coverage for VARIANT under 
`named_struct`/`struct_element`.



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