Skip to content
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

[cherry-pick-15957] : let preinsert can get outcnt from stats #16004

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 228 additions & 192 deletions pkg/pb/pipeline/pipeline.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/sql/colexec/preinsert/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Argument struct {
Attrs []string
IsUpdate bool

EstimatedRowCount int64

buf *batch.Batch

vm.OperatorBase
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ func (c *Compile) compilePlanScope(ctx context.Context, step int32, curNodeIdx i
currentFirstFlag := c.anal.isFirst
for i := range ss {
var preInsertArg *preinsert.Argument
preInsertArg, err = constructPreInsert(n, c.e, c.proc)
preInsertArg, err = constructPreInsert(ns, n, c.e, c.proc)
if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/compile/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ func dupInstruction(sourceIns *vm.Instruction, regMap map[*process.WaitRegister]
arg.Attrs = t.Attrs
arg.IsUpdate = t.IsUpdate
arg.HasAutoCol = t.HasAutoCol
arg.EstimatedRowCount = t.EstimatedRowCount
res.Arg = arg
case vm.Deletion:
t := sourceIns.Arg.(*deletion.Argument)
Expand Down Expand Up @@ -596,7 +597,7 @@ func constructFuzzyFilter(c *Compile, n, right *plan.Node) *fuzzyfilter.Argument
return arg
}

func constructPreInsert(n *plan.Node, eg engine.Engine, proc *process.Process) (*preinsert.Argument, error) {
func constructPreInsert(ns []*plan.Node, n *plan.Node, eg engine.Engine, proc *process.Process) (*preinsert.Argument, error) {
preCtx := n.PreInsertCtx
schemaName := preCtx.Ref.SchemaName

Expand Down Expand Up @@ -626,6 +627,7 @@ func constructPreInsert(n *plan.Node, eg engine.Engine, proc *process.Process) (
arg.TableDef = preCtx.TableDef
arg.Attrs = attrs
arg.IsUpdate = preCtx.IsUpdate
arg.EstimatedRowCount = int64(ns[n.Children[0]].Stats.Outcnt)

return arg, nil
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/sql/compile/scopeRemoteRun.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,12 @@ func convertToPipelineInstruction(opr *vm.Instruction, ctx *scopeContext, ctxId
}
case *preinsert.Argument:
in.PreInsert = &pipeline.PreInsert{
SchemaName: t.SchemaName,
TableDef: t.TableDef,
HasAutoCol: t.HasAutoCol,
IsUpdate: t.IsUpdate,
Attrs: t.Attrs,
SchemaName: t.SchemaName,
TableDef: t.TableDef,
HasAutoCol: t.HasAutoCol,
IsUpdate: t.IsUpdate,
Attrs: t.Attrs,
EstimatedRowCount: int64(t.EstimatedRowCount),
}
case *lockop.Argument:
in.LockOp = &pipeline.LockOp{
Expand Down Expand Up @@ -1135,6 +1136,7 @@ func convertToVmInstruction(opr *pipeline.Instruction, ctx *scopeContext, eng en
arg.Attrs = t.GetAttrs()
arg.HasAutoCol = t.GetHasAutoCol()
arg.IsUpdate = t.GetIsUpdate()
arg.EstimatedRowCount = int64(t.GetEstimatedRowCount())
v.Arg = arg
case vm.LockOp:
t := opr.GetLockOp()
Expand Down
13 changes: 7 additions & 6 deletions proto/pipeline.proto
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ message Deletion{
}

message PreInsert {
string schema_name = 1;
plan.TableDef table_def = 2;
repeated int32 idx = 3;
repeated string attrs = 4;
bool has_auto_col = 5;
bool is_update = 6;
string schema_name = 1;
plan.TableDef table_def = 2;
repeated int32 idx = 3;
repeated string attrs = 4;
bool has_auto_col = 5;
bool is_update = 6;
int64 estimated_row_count = 7;
}

message LockTarget {
Expand Down
Loading