Skip to content

Commit

Permalink
planner: support MaxOneRow clone (pingcap#33888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reminiscent authored Apr 15, 2022
1 parent b5de819 commit 56e1789
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions executor/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ func (e *NestedLoopApplyExec) Close() error {
} else {
runtimeStats.setCacheInfo(false, 0)
}
runtimeStats.SetConcurrencyInfo(execdetails.NewConcurrencyInfo("Concurrency", 0))
}
return e.outerExec.Close()
}
Expand Down
2 changes: 2 additions & 0 deletions planner/core/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ func enableParallelApply(sctx sessionctx.Context, plan PhysicalPlan) PhysicalPla
supportClone := err == nil // limitation 2
if noOrder && supportClone {
apply.Concurrency = sctx.GetSessionVars().ExecutorConcurrency
} else {
sctx.GetSessionVars().StmtCtx.AppendWarning(errors.Errorf("Some apply operators can not be executed in parallel"))
}

// because of the limitation 3, we cannot parallelize Apply operators in this Apply's inner size,
Expand Down
11 changes: 11 additions & 0 deletions planner/core/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,17 @@ type PhysicalMaxOneRow struct {
basePhysicalPlan
}

// Clone implements PhysicalPlan interface.
func (p *PhysicalMaxOneRow) Clone() (PhysicalPlan, error) {
cloned := new(PhysicalMaxOneRow)
base, err := p.basePhysicalPlan.cloneWithSelf(cloned)
if err != nil {
return nil, err
}
cloned.basePhysicalPlan = *base
return cloned, nil
}

// PhysicalTableDual is the physical operator of dual.
type PhysicalTableDual struct {
physicalSchemaProducer
Expand Down
5 changes: 5 additions & 0 deletions planner/core/planbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ func TestPhysicalPlanClone(t *testing.T) {
sel = sel.Init(ctx, stats, 0)
require.NoError(t, checkPhysicalPlanClone(sel))

// maxOneRow
maxOneRow := &PhysicalMaxOneRow{}
maxOneRow = maxOneRow.Init(ctx, stats, 0)
require.NoError(t, checkPhysicalPlanClone(maxOneRow))

// projection
proj := &PhysicalProjection{Exprs: []expression.Expression{col, cst}}
proj = proj.Init(ctx, stats, 0)
Expand Down

0 comments on commit 56e1789

Please sign in to comment.