[fix](lazy topn) V2: Fix slot-not-found after PullUpProjectExprUnderTopN with chained expressions #64486
[fix](lazy topn) V2: Fix slot-not-found after PullUpProjectExprUnderTopN with chained expressions #64486englefly wants to merge 2 commits into
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
TPC-H: Total hot run time: 29320 ms |
TPC-DS: Total hot run time: 169457 ms |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
TPC-H: Total hot run time: 29047 ms |
TPC-DS: Total hot run time: 169006 ms |
|
run cloud_p0 |
|
/review |
There was a problem hiding this comment.
I found one blocking correctness issue in the new bottom-up rewrite. The rule can now move aliases that canPullUp explicitly rejects when those aliases depend on a lower alias that was pulled up.
Critical checkpoint conclusions:
- Goal/test: The PR aims to fix slot-not-found/chained-expression behavior for
PullUpProjectExprUnderTopN; the added unit tests cover several nested TopN and rename cases, but miss the chained non-movable/volatile case below. - Scope: The change is focused to the Nereids rewrite and its unit test, but the replacement-map broadening changes semantic eligibility beyond the stated fix.
- Concurrency/lifecycle/config/compatibility/persistence: Not applicable; this is a logical optimizer rewrite with no new config, storage, protocol, or transaction persistence changes.
- Parallel paths: The affected path is the custom TopN expression pull-up rule used before lazy materialization; the lower lazy-materialization post processor still relies on this rule preserving expression movability constraints.
- Tests: I attempted
./run-fe-ut.sh --run org.apache.doris.nereids.rules.rewrite.PullUpProjectExprUnderTopNTest, but it failed before test execution becausethirdparty/installed/bin/protocis missing in this runner. - Observability/performance: No additional observability needed; performance intent is reasonable once the semantic guard is restored.
User focus: No additional user-provided review focus was present.
| @@ -237,37 +170,27 @@ public Plan visitLogicalTopN(LogicalTopN topN, CollectorContext context) { | |||
| * along the path from the TopN to the current node. An expression whose output ExprId | |||
| * is in this set cannot be pulled up past the operators that reference it. | |||
| */ | |||
There was a problem hiding this comment.
This records every alias in the replacement map, but later simplifyProject removes any alias whose inputs became unavailable and addUpperProject reconstructs it above the TopN. That bypasses canPullUp for aliases that were intentionally rejected. For example, with TopN -> Project(z = assert_true(x > 0)) -> Project(x = a + 1) -> Scan, x is pullable, so the lower project is simplified and x disappears from the upper project's child. Because z was also placed in pullUpExprReplaceMap, the upper project is removed and z = assert_true(a + 1 > 0) is restored above the TopN, even though AssertTrue is a NoneMovableFunction and canPullUp would have returned false for z. The same pattern applies to volatile/Score/L2Distance aliases. This can suppress errors or change semantics for rows discarded by TopN, so the replacement map needs to distinguish aliases that are safe to synthesize above TopN from aliases that must remain below it.
FE Regression Coverage ReportIncrement line coverage |
1 similar comment
FE Regression Coverage ReportIncrement line coverage |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)