seawinde opened a new pull request, #66182:
URL: https://github.com/apache/doris/pull/66182
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
An incremental materialized view COMPLETE refresh may plan the same
`INSERT OVERWRITE` statement twice using one `SessionVariable`. If the first
optimizer pass finds invalid statistics, it temporarily enables
`disable_join_reorder`. The second planning pass can therefore produce a
different analyzed join structure and IVM signature from the first pass or
a later incremental refresh.
**Root cause:** `SemiJoinCommute` ran in the Analyzer and read
`disable_join_reorder`. This made analyzed RIGHT OUTER, RIGHT SEMI, and
RIGHT ANTI join structures depend on planner state that can change between
planning passes.
**Change Summary:**
| File | Change |
|------|--------|
| `Analyzer.java` | Remove `SemiJoinCommute` from analysis so analyzed plans
remain stable |
| `Rewriter.java` | Run `SemiJoinCommute` in both normal and MV pre-rewrite
pipelines before `TransposeSemiJoin*` |
| `ReorderJoinTest.java` | Cover analysis/rewrite boundaries, disabled join
reorder, MV pre-rewrite, and rule ordering |
```mermaid
graph LR
A[Analyze RIGHT JOIN] --> B[Stable IVM signature]
A --> C[Rewrite]
C --> D{disable_join_reorder}
D -->|false| E[Normalize to LEFT JOIN]
D -->|true| F[Preserve RIGHT JOIN]
```
This keeps IVM signature generation independent of mutable optimizer state,
while preserving the existing join-reorder switch, LEADING hint, and
distribution-hint behavior during rewrite.
### Release note
Fix inconsistent incremental materialized view refresh planning when invalid
statistics change join-reorder state between COMPLETE refresh planning
passes.
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test
- [ ] No need to test or manual test
- Behavior changed:
- [x] No. This restores consistent IVM refresh planning.
- [ ] Yes.
- 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
--
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]