nsivarajan commented on code in PR #63974:
URL: https://github.com/apache/doris/pull/63974#discussion_r3594413358
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/query/QueryStatsRecorder.java:
##########
@@ -216,22 +239,43 @@ private static void walkPlan(Plan plan,
}
return;
}
- // TODO: PhysicalCTEConsumer slots use consumer-side ExprIds that
differ from the producer
- // scan's ExprIds, so CTE column stats are silently missed. Fix
requires mapping consumer
- // slots back to producer slots via
StatementContext.getConsumerToProducerSlotMap().
+ // PhysicalCTEProducer: walk its single child so the producer scan is
registered
+ // before any PhysicalCTEConsumer nodes are encountered during the
tree walk.
+ // Uses plan.children() for consistency with the rest of walkPlan.
+ if (plan instanceof PhysicalCTEProducer) {
+ walkPlan(plan.children().get(0),
+ exprIdToScan, exprIdToColName, deltas,
aggOutputToInputSlots);
+ return;
+ }
+ // PhysicalCTEConsumer: map consumer slots to producer scan slots so
parent
+ // plan nodes can resolve CTE column references correctly.
+ // Mapping is done before the children() loop so it is populated
regardless of
+ // whether the consumer has children — consistent with how scan
handlers work.
+ if (plan instanceof PhysicalCTEConsumer) {
+ PhysicalCTEConsumer cteConsumer = (PhysicalCTEConsumer) plan;
+ for (Slot consumerSlot : cteConsumer.getOutput()) {
+ Slot producerSlot = cteConsumer.getProducerSlot(consumerSlot);
+ PhysicalOlapScan sourceScan =
exprIdToScan.get(producerSlot.getExprId());
Review Comment:
Fixed — CTE consumer slots now link to producer slots unconditionally and
resolve through the shared recursive resolver, covered by
testCteConsumerOverComputedProducerColumnRecordsQueryHit.
--
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]