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


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

Review Comment:
   This generic propagation still misses scalar functions that consume a whole 
VARIANT but return a non-VARIANT type. For example, `SELECT variant_type(v) 
FROM variant_tbl WHERE v['k'] IS NOT NULL` visits `variant_type(v)` with an 
empty context; because the function result is `STRING`, this branch sends `v` 
through a fresh empty context and records no root `[v]` demand. The filter can 
then leave only `[v, k]` at the scan, even though `variant_type(v)` needs the 
root VARIANT value/type and can produce wrong results when the root is a 
primitive/array/object or otherwise not represented by the selected subpath. 
Please make whole-VARIANT-consuming scalar functions such as `variant_type` 
force a root access, and add coverage combining that scalar output with a 
sibling nested VARIANT predicate. This is distinct from the existing 
whole-output/cast/dynamic-subscript/generator threads because the consumer here 
returns a non-VARIANT value, so the current whole-VARIANT-output handling never 
run
 s.



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