-
Notifications
You must be signed in to change notification settings - Fork 6k
planner,indexjoin: Fix the panic of indexjoin + streamagg #60852
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3da8cc2
planner,indexjoin: Fix the panic of indexjoin + streamagg
elsa0520 b553565
delete unuse code
elsa0520 8350f33
fix build
elsa0520 55644a0
add dirty write test
elsa0520 4326e26
Update pkg/planner/core/exhaust_physical_plans.go
elsa0520 65a34ef
Update pkg/planner/core/exhaust_physical_plans.go
elsa0520 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 hidden or 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 |
---|---|---|
|
@@ -1950,15 +1950,45 @@ func constructIndexJoinInnerSideTaskWithAggCheck(p *logicalop.LogicalJoin, prop | |
if physicalIndexScan == nil && len(dsCopTask.indexPlan.Children()) == 1 { | ||
physicalIndexScan, _ = dsCopTask.indexPlan.Children()[0].(*PhysicalIndexScan) | ||
} | ||
// The double read case should change the table plan together, | ||
// so it need to find out the table scan | ||
// Try to get the physical table scan from dsCopTask.tablePlan | ||
// now, we only support the pattern tablescan and tablescan+selection | ||
var physicalTableScan *PhysicalTableScan | ||
if dsCopTask.tablePlan != nil { | ||
physicalTableScan, _ = dsCopTask.tablePlan.(*PhysicalTableScan) | ||
if physicalTableScan == nil && len(dsCopTask.tablePlan.Children()) == 1 { | ||
physicalTableScan, _ = dsCopTask.tablePlan.Children()[0].(*PhysicalTableScan) | ||
} | ||
Comment on lines
+1958
to
+1962
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. Is there any other case? Projection or UnionScan? 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. For now, there is no logic in the code. |
||
if physicalTableScan == nil { | ||
elsa0520 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
goto buildHashAgg | ||
winoros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
if physicalIndexScan != nil { | ||
physicalIndexScan.KeepOrder = true | ||
dsCopTask.keepOrder = true | ||
// Fix issue #60297, if index lookup(double read) as build side and table key is not common handle(row_id), | ||
// we need to reset extraHandleCol and needExtraProj. | ||
// The reason why the reset cop task needs to be specially modified here is that: | ||
// The cop task has been constructed in the previous logic, | ||
// but it was not possible to determine whether the stream agg was needed (that is, whether keep order was true). | ||
// Therefore, when updating the keep order, the relevant properties in the cop task need to be modified at the same time. | ||
// The following code is copied from the logic when keep order is true in function constructDS2IndexScanTask. | ||
if dsCopTask.tablePlan != nil && physicalTableScan != nil && !ds.TableInfo.IsCommonHandle { | ||
var needExtraProj bool | ||
dsCopTask.extraHandleCol, needExtraProj = physicalTableScan.appendExtraHandleCol(ds) | ||
dsCopTask.needExtraProj = dsCopTask.needExtraProj || needExtraProj | ||
} | ||
if dsCopTask.needExtraProj { | ||
dsCopTask.originSchema = ds.Schema() | ||
} | ||
streamAgg.SetStats(stats) | ||
aggTask = streamAgg.Attach2Task(dsCopTask) | ||
} | ||
} | ||
} | ||
|
||
buildHashAgg: | ||
// build hash agg, when the stream agg is illegal such as the order by prop is not matched | ||
if aggTask == nil { | ||
physicalHashAgg := NewPhysicalHashAgg(la, stats, prop) | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.