Skip to content

planner: simplify outer join other conditions#66015

Open
hawkingrei wants to merge 8 commits intomasterfrom
fix-65994-outer-join-predicate
Open

planner: simplify outer join other conditions#66015
hawkingrei wants to merge 8 commits intomasterfrom
fix-65994-outer-join-predicate

Conversation

@hawkingrei
Copy link
Member

What problem does this PR solve?

Issue Number: close #65994

Problem Summary:

  • OR logical constants in outer join other conditions (e.g. a=b OR 0) are not simplified, which prevents join key extraction and can lead to incorrect plans/results after predicate pushdown.

What changed and how does it work?

  • Apply predicate simplification to outer join OtherConditions to eliminate trivial OR constants and keep join keys.
  • Add regression coverage in predicate pushdown testdata and integration test for the OR-0 outer join case.
  • Record planner rule notes and test guidance updates.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/planner SIG: Planner labels Feb 4, 2026
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.6685%. Comparing base (6ff1adf) to head (e327656).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66015        +/-   ##
================================================
- Coverage   77.7600%   77.6685%   -0.0915%     
================================================
  Files          2001       1923        -78     
  Lines        546165     534896     -11269     
================================================
- Hits         424698     415446      -9252     
+ Misses       119805     119442       -363     
+ Partials       1662          8      -1654     
Flag Coverage Δ
integration 41.4917% <100.0000%> (-6.6949%) ⬇️
unit 76.7450% <100.0000%> (+0.3610%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8783% <ø> (-12.0935%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hawkingrei hawkingrei added type/bugfix This PR fixes a bug. type/stale This issue has not been updated for a long time. and removed do-not-merge/needs-triage-completed labels Feb 4, 2026
@hawkingrei
Copy link
Member Author

/check-issue-triage-complete

@hawkingrei
Copy link
Member Author

/retest

"select /* double_not_left_join_exec */ t0.k0, t2.k0 from t0 left join t2 on not not (t0.k0 = t2.k0) order by t0.k0, t2.k0",
"select /* double_not_right_join_exec */ t0.k0, t2.k0 from t0 right join t2 on not not (t0.k0 = t2.k0) order by t2.k0, t0.k0",
"select /* double_not_semi_join_exec */ t0.k0 from t0 where exists (select 1 from t2 where not not (t0.k0 = t2.k0)) order by t0.k0"
"select /* double_not_semi_join_exec */ t0.k0 from t0 where exists (select 1 from t2 where not not (t0.k0 = t2.k0)) order by t0.k0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's double_not_semi_join_exec a label for this test case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more like a comment or a prompt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where not not (t0.k0 = t2.k0))

@hawkingrei hawkingrei requested a review from qw4990 February 4, 2026 06:56
// However, we still need to eliminate obvious logical constants in OtherConditions
// (e.g. "a = b OR 0") to avoid losing join keys.
p.OtherConditions = ruleutil.ApplyPredicateSimplificationForJoin(
p.SCtx(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call this function for other join types, like semi/anti/inner?
Also we can move this function call inside PredicatePushDown, becase there is no much logic, and a new function seems meanless.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other LGTM

Copy link
Member Author

@hawkingrei hawkingrei Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I have rafactored this code.

@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 4, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guo-shaoge

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 4, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 4, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-02-04 08:12:42.548398664 +0000 UTC m=+254633.649797379: ☑️ agreed by guo-shaoge.

@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Correction Bugfix by AI AI-Testing approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bugfix This PR fixes a bug. type/stale This issue has not been updated for a long time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot simplify predicate with LEFT JOIN ON predicate rewritten as OR 0

3 participants