-
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: column pruning must reserve at least one column #54778
Conversation
allPruned := true | ||
for i, b := range used { | ||
if b || expression.ExprHasSetVarOrSleep(p.Exprs[i]) { | ||
// Set to true to avoid the ExprHasSetVarOrSleep be called multiple times. | ||
used[i] = true | ||
allPruned = false | ||
break | ||
} | ||
} | ||
if allPruned { | ||
_, ok := p.Children()[0].(*LogicalTableDual) | ||
if ok { | ||
// If the child is dual. The proj should not be eliminated. | ||
return p, nil | ||
} | ||
} |
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 the Proj->Dual
.
@@ -155,7 +177,7 @@ func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column, opt *opt | |||
// Current DataSource operator contains all the filters on this table, and the columns used by these filters are always included | |||
// in the output schema. Even if they are not needed by DataSource's parent operator. Thus add a projection here to prune useless columns | |||
// Limit to MPP tasks, because TiKV can't benefit from this now(projection can't be pushed down to TiKV now). | |||
if !addOneHandle && ds.Schema().Len() > len(parentUsedCols) && ds.SCtx().GetSessionVars().IsMPPEnforced() && ds.TableInfo.TiFlashReplica != nil { | |||
if !addOneHandle && ds.Schema().Len() > len(parentUsedCols) && len(parentUsedCols) > 0 && ds.SCtx().GetSessionVars().IsMPPEnforced() && ds.TableInfo.TiFlashReplica != nil { |
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.
We should not do the project if no column is required from its parent.
@@ -98,7 +101,7 @@ func (rs *resultReorder) injectSort(lp base.LogicalPlan) base.LogicalPlan { | |||
|
|||
func (*resultReorder) isInputOrderKeeper(lp base.LogicalPlan) bool { | |||
switch lp.(type) { | |||
case *LogicalSelection, *LogicalProjection, *LogicalLimit: | |||
case *LogicalSelection, *LogicalProjection, *LogicalLimit, *LogicalTableDual: |
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.
If we don't add this, we'll get Proj->Sort->Dual
for Proj->Dual
.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54778 +/- ##
================================================
+ Coverage 72.5717% 73.2215% +0.6497%
================================================
Files 1565 1573 +8
Lines 440170 447658 +7488
================================================
+ Hits 319439 327782 +8343
+ Misses 100937 99175 -1762
- Partials 19794 20701 +907
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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: elsa0520, time-and-fate The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
1 similar comment
/retest |
PR needs rebase. 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/test-infra repository. |
/merge |
@winoros: We have migrated to builtin 👉 Please use
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 ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: close #54777
Problem Summary:
What changed and how does it work?
Column pruning must reserve at least one column for correctness.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.