englefly opened a new pull request, #66803:
URL: https://github.com/apache/doris/pull/66803
### 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:
```text
Generate[UNNEST(tags#T2), ON tag#G = name#N] // name#N is stale after the
child outputs name#N2
Project[..., name#N2, ...]
Aggregate[..., ANY_VALUE(name)#N2, ...]
```
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 <!-- At least one of them must be included. -->
- [x] 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: <old id>`).
- Full `GenerateConjunctRewriteTest` /
`EliminateGroupByKeyByUniformTest` / `MergeGeneratesTest` / `FdTest` classes
are green.
- [ ] Regression test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
Internal correctness fix for plan rewriting; no intended plan-shape or
performance change.
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]