-
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, executor: fix the logic for inline projection of executors #45158
Merged
ti-chi-bot
merged 8 commits into
pingcap:master
from
winoros:fix-for-inline-proj-of-executors
Jul 12, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
102d180
planner, executor: fix the logic for inline projection of executors
winoros 1fe7e8d
fix all cases
winoros 0a2bcdd
fix make check
winoros 8c94521
fix for the CLUTER_* read
winoros 745d4df
fix the case that two plan might share the same output column slice
winoros 4193ce6
code clean
winoros 0a27608
fix that the cascades doesn't set output cols for limit
winoros 28843fd
Merge branch 'master' into fix-for-inline-proj-of-executors
winoros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,12 +121,33 @@ func (p *PhysicalHashJoin) ResolveIndicesItself() (err error) { | |
return err | ||
} | ||
} | ||
|
||
mergedSchema := expression.MergeSchema(lSchema, rSchema) | ||
|
||
for i, expr := range p.OtherConditions { | ||
p.OtherConditions[i], err = expr.ResolveIndices(expression.MergeSchema(lSchema, rSchema)) | ||
p.OtherConditions[i], err = expr.ResolveIndices(mergedSchema) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
colsNeedResolving := p.schema.Len() | ||
// The last output column of this two join is the generated column to indicate whether the row is matched or not. | ||
if p.JoinType == LeftOuterSemiJoin || p.JoinType == AntiLeftOuterSemiJoin { | ||
colsNeedResolving-- | ||
} | ||
// To avoid that two plan shares the same column slice. | ||
shallowColSlice := make([]*expression.Column, p.schema.Len()) | ||
copy(shallowColSlice, p.schema.Columns) | ||
p.schema = expression.NewSchema(shallowColSlice...) | ||
for i := 0; i < colsNeedResolving; i++ { | ||
newCol, err := p.schema.Columns[i].ResolveIndices(mergedSchema) | ||
if err != nil { | ||
return err | ||
} | ||
p.schema.Columns[i] = newCol.(*expression.Column) | ||
} | ||
|
||
return | ||
} | ||
|
||
|
@@ -173,12 +194,32 @@ func (p *PhysicalMergeJoin) ResolveIndices() (err error) { | |
return err | ||
} | ||
} | ||
|
||
mergedSchema := expression.MergeSchema(lSchema, rSchema) | ||
|
||
for i, expr := range p.OtherConditions { | ||
p.OtherConditions[i], err = expr.ResolveIndices(expression.MergeSchema(lSchema, rSchema)) | ||
p.OtherConditions[i], err = expr.ResolveIndices(mergedSchema) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
colsNeedResolving := p.schema.Len() | ||
// The last output column of this two join is the generated column to indicate whether the row is matched or not. | ||
if p.JoinType == LeftOuterSemiJoin || p.JoinType == AntiLeftOuterSemiJoin { | ||
colsNeedResolving-- | ||
} | ||
// To avoid that two plan shares the same column slice. | ||
shallowColSlice := make([]*expression.Column, p.schema.Len()) | ||
copy(shallowColSlice, p.schema.Columns) | ||
p.schema = expression.NewSchema(shallowColSlice...) | ||
for i := 0; i < colsNeedResolving; i++ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the only thing we can trust is the column.Index There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #45831 |
||
newCol, err := p.schema.Columns[i].ResolveIndices(mergedSchema) | ||
if err != nil { | ||
return err | ||
} | ||
p.schema.Columns[i] = newCol.(*expression.Column) | ||
} | ||
return | ||
} | ||
|
||
|
@@ -245,6 +286,24 @@ func (p *PhysicalIndexJoin) ResolveIndices() (err error) { | |
} | ||
p.OuterHashKeys[i], p.InnerHashKeys[i] = outerKey.(*expression.Column), innerKey.(*expression.Column) | ||
} | ||
|
||
colsNeedResolving := p.schema.Len() | ||
// The last output column of this two join is the generated column to indicate whether the row is matched or not. | ||
if p.JoinType == LeftOuterSemiJoin || p.JoinType == AntiLeftOuterSemiJoin { | ||
colsNeedResolving-- | ||
} | ||
// To avoid that two plan shares the same column slice. | ||
shallowColSlice := make([]*expression.Column, p.schema.Len()) | ||
copy(shallowColSlice, p.schema.Columns) | ||
p.schema = expression.NewSchema(shallowColSlice...) | ||
for i := 0; i < colsNeedResolving; i++ { | ||
newCol, err := p.schema.Columns[i].ResolveIndices(mergedSchema) | ||
if err != nil { | ||
return err | ||
} | ||
p.schema.Columns[i] = newCol.(*expression.Column) | ||
} | ||
|
||
return | ||
} | ||
|
||
|
@@ -618,6 +677,17 @@ func (p *PhysicalLimit) ResolveIndices() (err error) { | |
} | ||
p.PartitionBy[i].Col = newCol.(*expression.Column) | ||
} | ||
// To avoid that two plan shares the same column slice. | ||
shallowColSlice := make([]*expression.Column, p.schema.Len()) | ||
copy(shallowColSlice, p.schema.Columns) | ||
p.schema = expression.NewSchema(shallowColSlice...) | ||
for i, col := range p.schema.Columns { | ||
newCol, err := col.ResolveIndices(p.children[0].Schema()) | ||
if err != nil { | ||
return err | ||
} | ||
p.schema.Columns[i] = newCol.(*expression.Column) | ||
} | ||
return | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
limit schema will not always like what its children are, like its children are projection, and it may have been eliminated