Skip to content

branch-4.1: [fix](mv) Align extra-join elimination safety check #62527#63139

Merged
yiguolei merged 1 commit into
branch-4.1from
auto-pick-62527-branch-4.1
May 11, 2026
Merged

branch-4.1: [fix](mv) Align extra-join elimination safety check #62527#63139
yiguolei merged 1 commit into
branch-4.1from
auto-pick-62527-branch-4.1

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Cherry-picked from #62527

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>
@github-actions github-actions Bot requested a review from yiguolei as a code owner May 11, 2026 10:07
@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?

@hello-stephen
Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 71.43% (20/28) 🎉
Increment coverage report
Complete coverage report

@yiguolei
Copy link
Copy Markdown
Contributor

skip buildall

@yiguolei yiguolei merged commit 55d255f into branch-4.1 May 11, 2026
31 of 33 checks passed
Sign up for free to 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