nsivarajan commented on code in PR #63974:
URL: https://github.com/apache/doris/pull/63974#discussion_r3370840670


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/query/QueryStatsRecorder.java:
##########
@@ -125,19 +128,42 @@ static Map<String, StatsDelta> collectDeltas(PhysicalPlan 
plan) {
                 : plan.getOutput();
         for (NamedExpression ne : rootExprs) {
             SlotReference sr = unwrapAlias(ne);
-            if (sr == null) {
-                continue;
+            if (sr != null) {
+                PhysicalOlapScan sourceScan = exprIdToScan.get(sr.getExprId());
+                if (sourceScan != null) {
+                    StatsDelta delta = getOrCreateDelta(deltas, sourceScan);
+                    if (delta != null) {
+                        String colName = sr.getOriginalColumn().map(col -> 
col.getName())
+                                .orElseGet(() -> 
exprIdToColName.get(sr.getExprId()));
+                        if (colName != null) {
+                            delta.addQueryStats(colName);
+                        }
+                    }
+                    continue;
+                }
             }
-            PhysicalOlapScan sourceScan = exprIdToScan.get(sr.getExprId());
-            if (sourceScan == null) {
+            // Slot from a computed alias, or a complex root alias 
(Alias(a+b)): expand via map.
+            ExprId lookupId = (sr != null) ? sr.getExprId() : ne.getExprId();
+            Set<Slot> inputSlots = aggOutputToInputSlots.get(lookupId);
+            if (inputSlots == null) {
                 continue;
             }

Review Comment:
   Originally kept typed .child() thinking it was safer since PhysicalUnary 
guarantees non-null. Agreed that .children() is the right call for consistency 
across walkPlan.



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