-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
plan: push down constant filters over join properly #9848
Conversation
/run-all-tests |
OtherConditions
of join
Codecov Report
@@ Coverage Diff @@
## master #9848 +/- ##
===========================================
Coverage ? 77.2275%
===========================================
Files ? 405
Lines ? 81682
Branches ? 0
===========================================
Hits ? 63081
Misses ? 13926
Partials ? 4675 |
/run-all-tests |
/run-all-tests |
/rebuild |
/run-all-tests |
│ └─Selection_40 2.40 cop eq(3, test.t.a) | ||
│ └─IndexScan_39 3.00 cop table:s, index:b, range:[3,3], keep order:false | ||
└─TableReader_48 4.00 root data:Selection_47 | ||
└─Selection_47 4.00 cop eq(3, test.t.a) |
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.
For reviewers: the row count of Selection_47
and TableReader_48
is wrong, but this should be a separate issue and I would fix it in another PR later.
@@ -906,7 +906,7 @@ func (s *testPlanSuite) TestJoinReOrder(c *C) { | |||
}, | |||
{ | |||
sql: "select * from t o where o.b in (select t3.c from t t1, t t2, t t3 where t1.a = t3.a and t2.a = t3.a and t2.a = o.a and t1.a = 1)", | |||
best: "Apply{DataScan(o)->Join{Join{DataScan(t3)->DataScan(t1)}->DataScan(t2)}->Projection}->Projection", | |||
best: "Apply{DataScan(o)->Join{Join{DataScan(t1)->DataScan(t2)}->DataScan(t3)}->Projection}->Projection", |
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.
@winoros Please confirm this join order change does not effect correctness.
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.
THe join order changed since some filter pushed before but now is not.
@@ -180,6 +180,33 @@ func (b *PlanBuilder) buildResultSetNode(node ast.ResultSetNode) (p LogicalPlan, | |||
} | |||
} | |||
|
|||
// pushDownConstExpr checks if the condition is from filter condition, if true, push it down to both |
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.
What does filter
here mean?
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.
To differentiate the where conditions from join conditions, I use filter condition
here. I can change it to another name if it is misleading.
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.
So it should be the conditions exclude the join key conditions? If so, can deriveLeft || deriveRight
match its meaning?
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.
extractOnCondition
is called by PredicatePushDown
and atttachOnConds
, in PredicatePushDown
, the input conditions are treated as filter conditions, and at least deriveLeft
or deriveRight
is true; in attachOnConds
, the input conditions are join conditions, and deriveLeft
and deriveRight
are both false, so it should be correct?
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
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
What problem does this PR solve?
Fix #9843
What is changed and how it works?
For filter expression which does not contain columns:
Check List
Tests
Code changes
N/A
Side effects
N/A
Related changes