[fix](fe) Rewrite LogicalGenerate lateral conjuncts together with generators - #66803
Open
englefly wants to merge 1 commit into
Open
[fix](fe) Rewrite LogicalGenerate lateral conjuncts together with generators#66803englefly wants to merge 1 commit into
englefly wants to merge 1 commit into
Conversation
…erators
### What problem does this PR solve?
Problem Summary:
GenerateExpressionRewrite rewrote only LogicalGenerate.getGenerators() and
rebuilt the node via withGenerators(), which preserved the lateral ON
conjuncts unchanged. Whole-tree ExprId replacements (e.g. any_value wrapping
of a group-by key in EliminateGroupByKeyByUniform / EliminateGroupByKey) that
renamed a slot referenced by an ON conjunct therefore left the conjunct with a
stale ExprId after the child switched to the wrapped slot, and final slot
validation rejected the query.
Fix: GenerateExpressionRewrite now rewrites getConjuncts() in the same
operation and rebuilds the node with a new
LogicalGenerate.withGeneratorsAndConjuncts() helper, so generators and lateral
ON conjuncts stay consistent under any expression rewrite.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- New GenerateConjunctRewriteTest.testExprIdRewriterRewritesLateralConjuncts:
builds a LogicalGenerate with a conjunct referencing a slot, runs
ExprIdRewriter with an old->new ExprId map and asserts the conjunct is
rewritten (fails on the old code: expected 999 but was the old id).
- Full GenerateConjunctRewriteTest / EliminateGroupByKeyByUniformTest /
MergeGeneratesTest / FdTest classes are green.
- Behavior changed: No. Internal correctness fix for plan rewriting; no
intended plan-shape or performance change.
- Does this need documentation: No
englefly
requested review from
924060929,
morrySnow and
starocean999
as code owners
August 16, 2026 04:45
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
16 tasks
Contributor
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
TPC-H: Total hot run time: 17748 ms |
Contributor
TPC-DS: Total hot run time: 85219 ms |
Contributor
ClickBench: Total hot run time: 14.5 s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Problem Summary:
GenerateExpressionRewriterewrote onlyLogicalGenerate.getGenerators()and rebuilt the node viawithGenerators(), which preserved the lateral ON conjuncts unchanged. Whole-tree ExprId replacements (e.g.any_valuewrapping of a group-by key inEliminateGroupByKeyByUniform/EliminateGroupByKey) that renamed a slot referenced by an ON conjunct therefore left the conjunct with a stale ExprId after the child switched to the wrapped slot, and final slot validation rejected the query:Fix:
GenerateExpressionRewritenow rewritesgetConjuncts()in the same operation and rebuilds the node with a newLogicalGenerate.withGeneratorsAndConjuncts()helper, so generators and lateral ON conjuncts stay consistent under any expression rewrite.Release note
None
Check List (For Author)
Test
GenerateConjunctRewriteTest.testExprIdRewriterRewritesLateralConjuncts: builds aLogicalGeneratewith a conjunct referencing a slot, runsExprIdRewriterwith an old->new ExprId map and asserts the conjunct is rewritten (fails on the old code:expected: 999 but was: <old id>).GenerateConjunctRewriteTest/EliminateGroupByKeyByUniformTest/MergeGeneratesTest/FdTestclasses are green.Behavior changed:
Internal correctness fix for plan rewriting; no intended plan-shape or performance change.
Does this need documentation?
Check List (For Reviewer who merge this PR)