-
Notifications
You must be signed in to change notification settings - Fork 6.1k
planner: handle double NOT in outer join #65942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
539d0fa to
645443d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #65942 +/- ##
================================================
- Coverage 77.7249% 77.5746% -0.1504%
================================================
Files 2001 1923 -78
Lines 545885 533722 -12163
================================================
- Hits 424289 414033 -10256
+ Misses 119934 119683 -251
+ Partials 1662 6 -1656
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/test check-dev2 |
|
@qw4990: The specified target(s) for Use DetailsIn response to this:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where double NOT in outer join ON conditions (LEFT JOIN t2 ON NOT NOT (t0.k0 = t2.k0)) were not normalized, causing them to remain as "other conditions" and potentially leading to cartesian-like joins with incorrect results.
Changes:
- Added normalization step for outer join OtherConditions to apply PushDownNot when UnaryNot is present
- Enhanced PushDownNot to recognize and simplify double-NOT patterns for logical expressions
- Added comprehensive test cases for double-NOT in left/right/semi joins with both plan and result validation
- Added documentation to guide future optimizer development
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/planner/core/operator/logicalop/logical_join.go | Added normalizeJoinConditionsForOuterJoin() to apply PushDownNot on outer join OtherConditions when UnaryNot is present |
| pkg/expression/util.go | Enhanced pushNotAcrossExpr() to detect and simplify double-NOT patterns (NOT NOT expr) for logical expressions |
| pkg/expression/util_test.go | Added test cases for double-NOT simplification including comparison operations and multiple NOT levels |
| pkg/planner/core/casetest/rule/rule_predicate_pushdown_test.go | Added runPredicatePushdownTestDataWithResult() to validate both plans and execution results |
| pkg/planner/core/casetest/rule/testdata/*.json | Added test cases for double-NOT in various join types and updated schema to include Result field |
| docs/note/planner/rule/optimizer_ai_notes.md | Added documentation about the fix with background, implementation choices, and testing guidance |
| AGENTS.md | Added reference to optimizer notes documentation |
| .github/skills/tidb-test-guidelines/* | Updated test guidance for predicate pushdown cases |
AilinKid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest is good
qw4990
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please address @AilinKid 's comment before merging.
|
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
|
/retest |
|
@windtalker please take a look |
|
/retest |
| return | ||
| } | ||
| exprCtx := p.SCtx().GetExprCtx() | ||
| for i := range p.OtherConditions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like if only one of p.OtherConditions contains unary not, all the expression in p.OtherConditions will call expression.PushDownNot, it seems not necessary to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored it.
|
/hold |
5ed4824 to
7a76b40
Compare
windtalker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AilinKid, qw4990, windtalker, XuHuaiyu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
/retest |
What problem does this PR solve?
Issue Number: close #65937
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.