diff --git a/pkg/sql/colexec/restrict/types.go b/pkg/sql/colexec/restrict/types.go index b832802776bf1..75e879e8a535a 100644 --- a/pkg/sql/colexec/restrict/types.go +++ b/pkg/sql/colexec/restrict/types.go @@ -74,6 +74,10 @@ func (arg *Argument) SetExeExpr(e *plan.Expr) { arg.exeExpr = e } +func (arg *Argument) GetExeExpr() *plan.Expr { + return arg.exeExpr +} + func (arg *Argument) Free(proc *process.Process, pipelineFailed bool, err error) { if arg.ctr != nil { arg.ctr.cleanExecutor() diff --git a/pkg/sql/compile/operator.go b/pkg/sql/compile/operator.go index f720ac420356a..08a0cc9766039 100644 --- a/pkg/sql/compile/operator.go +++ b/pkg/sql/compile/operator.go @@ -274,7 +274,10 @@ func dupInstruction(sourceIns *vm.Instruction, regMap map[*process.WaitRegister] case vm.Restrict: t := sourceIns.Arg.(*restrict.Argument) arg := restrict.NewArgument() - arg.E = t.E + arg.E = t.GetExeExpr() + if arg.E == nil { + arg.E = t.E + } res.Arg = arg case vm.Semi: t := sourceIns.Arg.(*semi.Argument) diff --git a/pkg/sql/compile/remoterun.go b/pkg/sql/compile/remoterun.go index 31fb84a31c325..23cec0b1a0504 100644 --- a/pkg/sql/compile/remoterun.go +++ b/pkg/sql/compile/remoterun.go @@ -736,7 +736,10 @@ func convertToPipelineInstruction(opr *vm.Instruction, ctx *scopeContext, ctxId case *projection.Argument: in.ProjectList = t.Es case *restrict.Argument: - in.Filter = t.E + in.Filter = t.GetExeExpr() + if in.Filter == nil { + in.Filter = t.E + } case *semi.Argument: in.SemiJoin = &pipeline.SemiJoin{ Result: t.Result,