morningman commented on code in PR #69016:
URL: https://github.com/apache/doris/pull/69016#discussion_r4257770745


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathPlanCollector.java:
##########
@@ -125,9 +129,14 @@ public Void visitLogicalGenerate(LogicalGenerate<? extends 
Plan> generate, State
                             int colIndex = 
Integer.parseInt(colName.substring(StructLiteral.COL_PREFIX.length())) - 1;
                             CollectorContext argumentContext = new 
CollectorContext(context, false);
                             argumentContext.setType(accessPath.getType());
-                            if 
(function.child(colIndex).getDataType().isVariantType()) {
-                                argumentContext.getAccessPathBuilder()
-                                        .addSuffix(path.subList(2, 
path.size()));
+                            if 
(function.child(colIndex).getDataType().isVariantType()
+                                    && 
!isNestedGroupVariant(function.child(colIndex))) {
+                                // Every Variant argument determines the 
generated array shape, so
+                                // an output-field path must not narrow the 
input container.
+                                
exprCollector.collect(function.child(colIndex));

Review Comment:
   Fixed in ae194a48b0e. Confirmed: the multi-argument branch collected the 
whole container only for the Variant arguments whose generated field the query 
referenced (branch-4.2 has the same code), while a multi-argument explode 
generates as many rows as its longest argument 
(`VExplodeV2TableFunction::process_row`), so an unread argument still shapes 
the output. `AccessPathPlanCollector` now collects the whole container of every 
ordinary Variant argument of a multi-argument explode before it handles the 
referenced fields; NestedGroup arguments keep their exact paths as before.
   
   `testMultiArgumentExplodeKeepsUnreadVariantArgumentContainer` covers your 
shape (`x1['k'], v2['k']` over `explode(v1, v2)`) and the mirrored 
`explode_outer` case (`x2['k'], v1['k']`). It runs with Variant sub-path 
pruning off: that rule only rewrites OLAP scans, so it models an external file 
scan, where `v2['k']` and the explode argument share one slot. Without the fix 
the first case fails with `[DATA:v2.k]` for `v2`.
   



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