Uh oh!
There was an error while loading. Please reload this page.
[fix](eager-agg) Handle duplicate aggregate functions pushed through projects - #66531
Conversation
hello-stephen
commented
Aug 6, 2026
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
feiniaofeiafei
commented
Aug 6, 2026
run buildall |
hello-stephen
commented
Aug 6, 2026
FE Regression Coverage ReportIncrement line coverage |
feiniaofeiafei
commented
Aug 6, 2026
run buildall |
hello-stephen
commented
Aug 6, 2026
TPC-H: Total hot run time: 28827 ms |
hello-stephen
commented
Aug 6, 2026
TPC-DS: Total hot run time: 166510 ms |
hello-stephen
commented
Aug 6, 2026
ClickBench: Total hot run time: 23.7 s |
hello-stephen
commented
Aug 6, 2026
FE Regression Coverage ReportIncrement line coverage |
| } | ||
| boolean needDifferentExprId = aggFunctions.size() != context.getAliasMap().size(); |
There was a problem hiding this comment.
这一轮遍历可以省略, 判断去重可以在 L429 这个 for 循环里一次完成
feiniaofeiafei
commented
Aug 10, 2026
run buildall |
hello-stephen
commented
Aug 10, 2026
FE UT Coverage ReportIncrement line coverage |
hello-stephen
commented
Aug 10, 2026
FE Regression Coverage ReportIncrement line coverage |
feiniaofeiafei
commented
Aug 10, 2026
run performance |
4 similar comments
feiniaofeiafei
commented
Aug 10, 2026
run performance |
feiniaofeiafei
commented
Aug 10, 2026
run performance |
feiniaofeiafei
commented
Aug 10, 2026
run performance |
feiniaofeiafei
commented
Aug 10, 2026
run performance |
hello-stephen
commented
Aug 10, 2026
TPC-H: Total hot run time: 29318 ms |
hello-stephen
commented
Aug 10, 2026
TPC-DS: Total hot run time: 159105 ms |
hello-stephen
commented
Aug 10, 2026
ClickBench: Total hot run time: 23.91 s |
feiniaofeiafei
commented
Aug 11, 2026
run buildall |
hello-stephen
commented
Aug 11, 2026
TPC-H: Total hot run time: 29000 ms |
hello-stephen
commented
Aug 11, 2026
TPC-DS: Total hot run time: 157959 ms |
hello-stephen
commented
Aug 11, 2026
ClickBench: Total hot run time: 23.63 s |
hello-stephen
commented
Aug 11, 2026
FE UT Coverage ReportIncrement line coverage |
hello-stephen
commented
Aug 11, 2026
FE Regression Coverage ReportIncrement line coverage |
Uh oh!
There was an error while loading. Please reload this page.
…projects (apache#66531) ### What problem does this PR solve? Related PR: apache#63690 Problem Summary: Eager aggregation pushdown may fail when different aggregate functions become the same expression after passing through a Project. report error: ```text 2026-08-06 04:26:54,285 INFO (mysql-nio-pool-14|325) [PushDownAggregation.visitLogicalAggregate():280] PushDownAggregation failed: Cannot invoke "org.apache.doris.nereids.trees.expressions.NamedExpression.toSlot()" because "namedExpression" is null at org.apache.doris.nereids.rules.rewrite.eageraggregation.EagerAggRewriter.visitLogicalProject(EagerAggRewriter.java:718) at org.apache.doris.nereids.rules.rewrite.eageraggregation.EagerAggRewriter.visitLogicalProject(EagerAggRewriter.java:90) at org.apache.doris.nereids.trees.plans.logical.LogicalProject.accept(LogicalProject.java:160) at org.apache.doris.nereids.rules.rewrite.eageraggregation.EagerAggRewriter.visitLogicalUnion(EagerAggRewriter.java:582) at org.apache.doris.nereids.rules.rewrite.eageraggregation.EagerAggRewriter.visitLogicalUnion(EagerAggRewriter.java:90) at org.apache.doris.nereids.trees.plans.logical.LogicalUnion.accept(LogicalUnion.java:155) ``` For example: ```text Aggregate: SUM(x)#4, SUM(y)apache#5 Union All Project: 0 AS x, 0 AS y Join ``` After pushing the aggregates through the Project, both functions become`SUM(0)`: ```text functions: [SUM(0), SUM(0)] aliasMap: SUM(0) -> apache#5 ``` Because `aliasMap` uses expression equality, only one entry is retained. The Project still tries to read both `#4` and `apache#5` from `BilateralState`, causing a null lookup. This PR deduplicates the child aggregate and records the ExprId mapping: ```text child aggregate: SUM(0) -> apache#8 ExprId mapping: #4 -> apache#8, apache#5 -> apache#8 ``` The Project then restores both required outputs: ```text slot#8 AS slot#4 slot#8 AS slot#5 ``` When no aggregate functions are merged, the original ExprIds are reused to avoid unnecessary aliases. The same fix also covers cases such as: ```text Project: a#1 AS x, a#1 AS y ``` where `SUM(x)` and `SUM(y)` both become `SUM(a#1)` after pushdown. ### Release note None ### Check List (For Author) - Test - [x] Regression test - `query_p0/eager_agg/bilateral_eager_agg` - Covers two aggregate functions that become the same function after Project pushdown. - [ ] Unit Test - [ ] Manual test - [ ] No need to test or manual test. - Behavior changed: - [x] Yes. - Prevents eager aggregation pushdown from failing when multiple aggregate functions become identical after Project rewriting. - `eager_aggregation_mode=1` can force eligible pushdown after a UNION. - Does this need documentation? - [x] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label
What problem does this PR solve?
Related PR: #63690
Problem Summary:
Eager aggregation pushdown may fail when different aggregate functions become
the same expression after passing through a Project. report error:
For example:
After pushing the aggregates through the Project, both functions become
SUM(0):Because
aliasMapuses expression equality, only one entry is retained.The Project still tries to read both
#4and#5fromBilateralState,causing a null lookup.
This PR deduplicates the child aggregate and records the ExprId mapping:
The Project then restores both required outputs:
When no aggregate functions are merged, the original ExprIds are reused to
avoid unnecessary aliases.
The same fix also covers cases such as:
where
SUM(x)andSUM(y)both becomeSUM(a#1)after pushdown.Release note
None
Check List (For Author)
Test
query_p0/eager_agg/bilateral_eager_aggProject pushdown.
Behavior changed:
aggregate functions become identical after Project rewriting.
eager_aggregation_mode=1can force eligible pushdown after a UNION.Does this need documentation?
Check List (For Reviewer who merge this PR)