Skip to content

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.0458%. Comparing base (6ff1adf) to head (706bd54).
⚠️ Report is 2 commits behind head on master.

⚠️ Current head 706bd54 differs from pull request most recent head 75e4a70

Please upload reports for the commit 75e4a70 to get more accurate results.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66015        +/-   ##
================================================
- Coverage   77.7600%   77.0458%   -0.7142%     
================================================
  Files          2001       1923        -78     
  Lines        546165     534566     -11599     
================================================
- Hits         424698     411861     -12837     
- Misses       119805     122697      +2892     
+ Partials       1662          8      -1654     
Flag Coverage Δ
unit 76.0531% <100.0000%> (-0.3309%) ⬇️

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

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7021% <ø> (-12.2697%) ⬇️
🚀 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]>
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 4, 2026

@hawkingrei: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/check_dev_2 706bd54 link true /test check-dev2
idc-jenkins-ci-tidb/check_dev 706bd54 link true /test check-dev
idc-jenkins-ci-tidb/build 26765e7 link true /test build
idc-jenkins-ci-tidb/mysql-test 75e4a70 link true /test mysql-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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.

Wrong results with LEFT JOIN ON predicate rewritten as OR 0

4 participants