-
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
planner/cascades: add transformation rule PushTopNDownUnionAll #14078
Conversation
Codecov Report
@@ Coverage Diff @@
## master #14078 +/- ##
===========================================
Coverage ? 80.1546%
===========================================
Files ? 483
Lines ? 121540
Branches ? 0
===========================================
Hits ? 97420
Misses ? 16362
Partials ? 7758 |
|
||
newTopN.ByItems = make([]*plannercore.ByItems, 0, len(topN.ByItems)) | ||
for _, by := range topN.ByItems { | ||
newTopN.ByItems = append(newTopN.ByItems, &plannercore.ByItems{by.Expr, by.Desc}) |
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.
Have you ever test TopN
by items from different union children? I guess you should divide the TopN
by each child's schema.
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.
PlanBuilder ensures that all of the UnionAll's children have the same schema, by adding Projections below the UnionAll. So we have no need to deal with the schema here. It will be done by PushTopNDownProjection
.
|
||
newTopN.ByItems = make([]*plannercore.ByItems, 0, len(topN.ByItems)) | ||
for _, by := range topN.ByItems { | ||
newTopN.ByItems = append(newTopN.ByItems, &plannercore.ByItems{by.Expr, by.Desc}) |
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.
PlanBuilder ensures that all of the UnionAll's children have the same schema, by adding Projections below the UnionAll. So we have no need to deal with the schema here. It will be done by PushTopNDownProjection
.
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.
Please add a test which topN has both offset and count.
To #14214 |
What problem does this PR solve?
This PR adds Transformation rule PushTopNDownUnionAll, which is a part of TopN push down in cascades planner.
What is changed and how it works?
The logic is the same with
planner/core/rule_topn_push_down.go
/LogicalUnion.pushDownTopN
.Check List
Tests