branch-4.1: [fix](mv) Align extra-join elimination safety check #62527#63139
Merged
Conversation
Problem Summary:
Extra-join elimination rejected some safe LEFT JOIN rewrites too early.
When the right side was guaranteed unique, a LEFT JOIN could still be
safely eliminated even if its ON clause contained right-side
`otherJoinConjuncts`, because those predicates only decide whether the
nullable side matches and do not filter preserved-side rows.
Example:
-- MV
SELECT t1.id, t1.name
FROM t1
LEFT JOIN t2
ON t1.id = t2.id AND t2.id = 1
-- Query
SELECT id, name FROM t1
If `t2.id` is unique and no output or residual filter depends on `t2`,
eliminating `t2` is safe.
This PR relaxes the MV comparison path for that LEFT JOIN case, while
still rejecting eliminations when unmatched residual filters depend on
the eliminated side. For example, filters above the join such as `WHERE
t2.id IS NULL`, or INNER JOIN filters such as `WHERE lineitem.l_shipdate
= '2024-01-01'`, cannot be dropped because they affect which
preserved-side rows survive.
To make that safety check precise, `FilterEdge` now records the actual
input nodes of its predicates during HyperGraph construction, including
projected aliases and slot-free predicates.
Co-authored-by: yangtao555 <yangtao555@jd.com>
Co-authored-by: Dongyang Li <lidongyang@selectdb.com>
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
|
skip buildall |
yiguolei
approved these changes
May 11, 2026
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.
Cherry-picked from #62527