nsivarajan commented on code in PR #63974:
URL: https://github.com/apache/doris/pull/63974#discussion_r3594417265
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/query/QueryStatsRecorder.java:
##########
@@ -384,22 +506,47 @@ private static void recordInputSlotsAsQueryHit(Expression
expr,
private static void recordInputSlotsAsFilterHit(Expression expr,
Map<ExprId, PhysicalOlapScan> exprIdToScan,
Map<ExprId, String> exprIdToColName,
- Map<String, StatsDelta> deltas) {
+ Map<String, StatsDelta> deltas,
+ Map<ExprId, Set<Slot>> aggOutputToInputSlots) {
for (Slot slot : expr.getInputSlots()) {
if (!(slot instanceof SlotReference)) {
continue;
}
SlotReference sr = (SlotReference) slot;
PhysicalOlapScan sourceScan = exprIdToScan.get(sr.getExprId());
- if (sourceScan == 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.addFilterStats(colName);
+ 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.addFilterStats(colName);
+ }
+ }
+ } else {
+ // Slot not from a scan — check if it is a multi-input
aggregate output
+ // (e.g. SUM(k2+k3)) and expand to its contributing input
slots.
+ Set<Slot> inputSlots =
aggOutputToInputSlots.get(sr.getExprId());
Review Comment:
Fixed — replaced the single-hop map with derivedSlotInputs + a recursive
resolver that walks arbitrarily many computed hops, covered by
testNestedSingleInputHavingOverComputedColumnRecordsFilterHit.
--
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]