nsivarajan commented on code in PR #63974:
URL: https://github.com/apache/doris/pull/63974#discussion_r3370860513
##########
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;
}
- 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);
+ for (Slot slot : inputSlots) {
+ if (!(slot instanceof SlotReference)) {
+ continue;
+ }
+ SlotReference inputSr = (SlotReference) slot;
Review Comment:
Initially had the early return since CTEConsumer has no children today,
thinking the explicit exit was cleaner. Your point on consistency is right —
scan nodes (OlapScan, LazyMaterializeOlapScan) follow the fall-through pattern
without an explicit return, so CTEConsumer should too. Removed.
--
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]