Uh oh!
There was an error while loading. Please reload this page.
branch-4.0:[fix](mtmv) Avoid invalid slot cast in MV null-reject compensation (#66613) - #67255
Open
seawinde wants to merge 1 commit into
Open
branch-4.0:[fix](mtmv) Avoid invalid slot cast in MV null-reject compensation (#66613)#67255seawinde wants to merge 1 commit into
seawinde wants to merge 1 commit into
Conversation
…pache#66613) Related PR: apache#43539, apache#62492, apache#63268 Problem Summary: When an INNER JOIN query is matched against a LEFT OUTER JOIN materialized view, the rewrite must prove that the nullable side is null-rejected. The MV rule shuttles the nullable-side output Slots through the view plan lineage to normalize Project and Alias outputs before selecting an `IS NOT NULL` compensation Slot. **Root cause:** `AbstractMaterializedViewRule.getShuttledRequireNoNullableViewSlots()` assumed that `ExpressionUtils.shuttleExpressionWithLineage()` always returns `Slot` values and unconditionally used `Slot.class::cast`. The API returns general `Expression` values. Expression JOIN keys such as CAST equality can introduce helper projections whose lineage expands to `Cast`, causing a `ClassCastException` during MV rewrite. The unsafe assumption was introduced by apache#43539. PR apache#62492 added INNER JoinEdge null-reject inference, and apache#63268 materialized that evidence as compensation, making this path more readily reachable. **Current limitation:** This is a conservative crash fix, not transparent rewrite support for CAST or arbitrary derived expressions. If no usable Slot remains after lineage expansion, the existing proof checks return invalid and the MV rewrite safely falls back to base tables. The CAST JOIN case covered by the test therefore still does not use the MV. Using an expression's input Slots as compensation evidence is not generally sound because functions and casts can change nullability semantics; supporting such expressions requires an explicit nullability-preserving proof. Fixed an internal `ClassCastException` during materialized view rewrite for expression-based join keys. Unsupported derived-expression lineage now falls back safely.
hello-stephen
commented
Aug 28, 2026
Contributor
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
seawinde
commented
Aug 28, 2026
MemberAuthor
run buildall |
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 freeto 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.
pr: #66613
commitId: 7128b3e