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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -313,6 +329,18 @@ public Void visitElementAt(ElementAt elementAt, 
CollectorContext context) {
                 return continueCollectAccessPath(first, context);
             }
             return visit(elementAt, context);
+        } else if (first.getDataType().isVariantType() && arguments.size() >= 
2) {
+            if (first instanceof SlotReference && !((SlotReference) 
first).hasSubColPath()
+                    && context.accessPathBuilder.isEmpty()) {
+                recordVariantRootAccessPath((SlotReference) first, context);
+            } else {
+                continueCollectAccessPath(first, new 
CollectorContext(context.statementContext,

Review Comment:
   This still misses full-root demand when a dynamic VARIANT subscript is 
applied to a VARIANT-valued expression instead of a bare slot. For example, 
`SELECT element_at(if(flag, v1, v2), cast(id AS string)) FROM t WHERE v1['k'] 
IS NOT NULL` reaches this branch with `first` as the `if` expression; 
`continueCollectAccessPath()` then visits its children with an empty builder, 
so neither `v1` nor `v2` is recorded as a root read. The filter can still 
contribute only `[v1, k]`, so `v1` may be pruned even though the dynamic lookup 
can read any key. The literal-key branch above has the same non-slot 
propagation problem for `element_at(if(flag, v1, v2), 'k')`, where the `k` 
demand is dropped by the default visitor. Please propagate the required VARIANT 
access through expression children or conservatively record root access for 
every VARIANT slot under the non-slot expression, and add coverage combining 
such an expression with a sibling predicate. This is distinct from the existing 
direct `v[d
 ynamic_key]` thread because the VARIANT input here is not a `SlotReference`.



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