planner, expression: support predicate pushdown for CTE#28204
planner, expression: support predicate pushdown for CTE#28204wjhuang2016 wants to merge 5 commits intopingcap:masterfrom
Conversation
|
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by submitting an approval review. |
expression/util.go
Outdated
| } | ||
|
|
||
| // ExtractColumnSetSimple extracts the different values of `UniqueId` for columns in expressions. | ||
| func ExtractColumnSetSimple(expr Expression) *intsets.Sparse { |
There was a problem hiding this comment.
You can change the �ExtractColumnSet's signature to ExtractColumnSet(exprs ...Expression).
Then you can easily call it by ExtractColumnSet(a), ExtractColumnSet(a, b), Extract(exprSlice...).
This way we don't need two functions.
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
| } | ||
| var p LogicalPlan | ||
| lp := LogicalCTE{cteAsName: tn.Name, cte: cte.cteClass, seedStat: cte.seedStat}.Init(b.ctx, b.getSelectOffset()) | ||
| prevSchema := cte.seedLP.Schema().Clone() |
| if p.cte.seedPartPhysicalPlan == nil { | ||
| // Build push-downed predicates. | ||
| if len(p.cte.pushDownPredicates) > 0 && p.cte.recursivePartLogicalPlan == nil { | ||
| selectedPushDownPredicates := make([]expression.Expression, 0) |
| selectedPushDownPredicates := make([]expression.Expression, 0) | ||
| minColSet := expression.IntersectColumnSet(p.cte.pushDownPredicates) | ||
| for _, cond := range p.cte.pushDownPredicates { | ||
| cnfItems := expression.SplitCNFItems(cond) |
There was a problem hiding this comment.
The pushDownPredicates should already be in CNF form. Thus each of its items should be a DNF case. Why do we call SplitCNFItems here?
|
|
||
| var err error | ||
| if p.cte.seedPartPhysicalPlan == nil { | ||
| // Build push-downed predicates. |
There was a problem hiding this comment.
We can add more comments to illustrate the codes here.
Signed-off-by: wjhuang2016 huangwenjun1997@gmail.com
What problem does this PR solve?
Issue Number: close #28163
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
How it Works:
Check List
Tests
Side effects
Documentation
Release note