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


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/query/QueryStatsRecorder.java:
##########
@@ -170,17 +196,14 @@ static boolean shouldRecord(StatementContext ctx) {
     }
 
     /**
-     * Single-pass tree walk: registers scan output slots into exprIdToScan,
-     * records filterHit for WHERE conjuncts, and records queryHit for
-     * GROUP BY / ORDER BY / window keys and aggregate input columns.
-     * Children are visited before the current node so scans are registered 
first.
-     * PhysicalLazyMaterializeOlapScan is checked before PhysicalOlapScan
-     * because it is a subclass; the inner scan's metadata must be used.
+     * Single-pass tree walk: registers scan slots, records filterHit for 
WHERE/JOIN conditions,
+     * and queryHit for GROUP BY / ORDER BY / window keys and aggregate inputs.
      */
     private static void walkPlan(Plan plan,

Review Comment:
   Great question! The core reason is the traversal order.
   
   The tree walk must be strictly post-order because scan slots need to be 
registered by the child/leaf nodes before parent nodes (like filters, 
aggregates, or joins) can look up those slots to map their conditions.
   
   Since DefaultPlanVisitor executes its logic pre-order by default, using it 
here would require every overridden method to manually trigger child recursion 
first before executing its own logic, which inverts the natural visitor 
contract and can be error-prone.
   
   If you prefer consistency with the rest of the codebase, I can absolutely 
refactor this to a visitor pattern in a follow-up PR when we expand query stats 
support!



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