Skip to content

branch-4.1:[fix](mtmv) Avoid invalid slot cast in MV null-reject compensation (#66613) - #67266

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
seawinde:pr_66613_to_branch-4.1
Aug 28, 2026
Merged

branch-4.1:[fix](mtmv) Avoid invalid slot cast in MV null-reject compensation (#66613)#67266
yiguolei merged 1 commit into
apache:branch-4.1from
seawinde:pr_66613_to_branch-4.1

Conversation

@seawinde

Copy link
Copy Markdown
Member

pr: #66613
commitId: a97548f

…pache#66613)
### What problem does this PR solve?
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.
`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.
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.
### Release note
Fixed an internal `ClassCastException` during materialized view rewrite for
expression-based join keys. Unsupported derived-expression lineage now falls
back safely.
### Check List (For Author)
- Test: Unit Test
- `NullRejectInferenceTest`
- Behavior changed: Yes, unsupported derived-expression lineage falls back instead of throwing
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@seawinde

Copy link
Copy Markdown
MemberAuthor

run buildall

@yiguolei
yiguolei merged commit 1d465f6 into apache:branch-4.1Aug 28, 2026
29 of 32 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@seawinde@hello-stephen@yiguolei