Skip to content

Commit 427434a

Browse files
committed
address comment
Signed-off-by: Lonng <heng@lonng.org>
1 parent 98b631b commit 427434a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

expression/aggregation/agg_to_pb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func AggFuncToPBExpr(sc *stmtctx.StatementContext, client kv.Client, aggFunc *Ag
5656

5757
children := make([]*tipb.Expr, 0, len(aggFunc.Args))
5858
for _, arg := range aggFunc.Args {
59-
pbArg := pc.ExprToPB(sc, arg)
59+
pbArg := pc.ExprToPB(arg)
6060
if pbArg == nil {
6161
return nil
6262
}

expression/expr_to_pb.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ExpressionsToPB(sc *stmtctx.StatementContext, exprs []Expression, client kv
4545
}
4646

4747
for _, expr := range exprs {
48-
pbExpr := pc.ExprToPB(sc, expr)
48+
pbExpr := pc.ExprToPB(expr)
4949
if pbExpr == nil {
5050
remained = append(remained, expr)
5151
continue
@@ -72,7 +72,7 @@ func ExpressionsToPB(sc *stmtctx.StatementContext, exprs []Expression, client kv
7272
func ExpressionsToPBList(sc *stmtctx.StatementContext, exprs []Expression, client kv.Client) (pbExpr []*tipb.Expr) {
7373
pc := PbConverter{client: client, sc: sc}
7474
for _, expr := range exprs {
75-
v := pc.ExprToPB(sc, expr)
75+
v := pc.ExprToPB(expr)
7676
pbExpr = append(pbExpr, v)
7777
}
7878
return
@@ -90,14 +90,14 @@ func NewPBConverter(client kv.Client, sc *stmtctx.StatementContext) PbConverter
9090
}
9191

9292
// ExprToPB converts Expression to TiPB.
93-
func (pc PbConverter) ExprToPB(sc *stmtctx.StatementContext, expr Expression) *tipb.Expr {
93+
func (pc PbConverter) ExprToPB(expr Expression) *tipb.Expr {
9494
switch x := expr.(type) {
9595
case *Constant, *CorrelatedColumn:
9696
return pc.conOrCorColToPBExpr(expr)
9797
case *Column:
9898
return pc.columnToPBExpr(x)
9999
case *ScalarFunction:
100-
return pc.scalarFuncToPBExpr(sc, x)
100+
return pc.scalarFuncToPBExpr(x)
101101
}
102102
return nil
103103
}
@@ -221,7 +221,7 @@ func (pc PbConverter) columnToPBExpr(column *Column) *tipb.Expr {
221221
Val: codec.EncodeInt(nil, id)}
222222
}
223223

224-
func (pc PbConverter) scalarFuncToPBExpr(sc *stmtctx.StatementContext, expr *ScalarFunction) *tipb.Expr {
224+
func (pc PbConverter) scalarFuncToPBExpr(expr *ScalarFunction) *tipb.Expr {
225225
// check whether this function can be pushed.
226226
if !pc.canFuncBePushed(expr) {
227227
return nil
@@ -236,7 +236,7 @@ func (pc PbConverter) scalarFuncToPBExpr(sc *stmtctx.StatementContext, expr *Sca
236236
// check whether all of its parameters can be pushed.
237237
children := make([]*tipb.Expr, 0, len(expr.GetArgs()))
238238
for _, arg := range expr.GetArgs() {
239-
pbArg := pc.ExprToPB(sc, arg)
239+
pbArg := pc.ExprToPB(arg)
240240
if pbArg == nil {
241241
return nil
242242
}
@@ -245,7 +245,7 @@ func (pc PbConverter) scalarFuncToPBExpr(sc *stmtctx.StatementContext, expr *Sca
245245

246246
var implicitParameters []byte
247247
if params := expr.Function.implicitParameters(); len(params) > 0 {
248-
encoded, err := codec.EncodeValue(sc, nil, params...)
248+
encoded, err := codec.EncodeValue(pc.sc, nil, params...)
249249
if err != nil {
250250
logutil.Logger(context.Background()).Error("encode implicit parameters", zap.Any("datums", params), zap.Error(err))
251251
return nil
@@ -266,7 +266,7 @@ func (pc PbConverter) scalarFuncToPBExpr(sc *stmtctx.StatementContext, expr *Sca
266266
// GroupByItemToPB converts group by items to pb.
267267
func GroupByItemToPB(sc *stmtctx.StatementContext, client kv.Client, expr Expression) *tipb.ByItem {
268268
pc := PbConverter{client: client, sc: sc}
269-
e := pc.ExprToPB(sc, expr)
269+
e := pc.ExprToPB(expr)
270270
if e == nil {
271271
return nil
272272
}
@@ -276,7 +276,7 @@ func GroupByItemToPB(sc *stmtctx.StatementContext, client kv.Client, expr Expres
276276
// SortByItemToPB converts order by items to pb.
277277
func SortByItemToPB(sc *stmtctx.StatementContext, client kv.Client, expr Expression, desc bool) *tipb.ByItem {
278278
pc := PbConverter{client: client, sc: sc}
279-
e := pc.ExprToPB(sc, expr)
279+
e := pc.ExprToPB(expr)
280280
if e == nil {
281281
return nil
282282
}

expression/expr_to_pb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func (s *testEvaluatorSuite) TestImplicitParameters(c *C) {
608608
// InUnion flag is false in `BuildCastFunction` when `ScalarFuncSig_CastStringAsInt`
609609
cast := BuildCastFunction(mock.NewContext(), dg.genColumn(mysql.TypeString, 1), types.NewFieldType(mysql.TypeLonglong))
610610
c.Assert(cast.(*ScalarFunction).Function.implicitParameters(), DeepEquals, []types.Datum{types.NewIntDatum(0)})
611-
expr := pc.ExprToPB(sc, cast)
611+
expr := pc.ExprToPB(cast)
612612
c.Assert(expr.Sig, Equals, tipb.ScalarFuncSig_CastStringAsInt)
613613
c.Assert(len(expr.Val), Greater, 0)
614614
datums, err := codec.Decode(expr.Val, 1)
@@ -618,14 +618,14 @@ func (s *testEvaluatorSuite) TestImplicitParameters(c *C) {
618618
// InUnion flag is nil in `BuildCastFunction4Union` when `ScalarFuncSig_CastIntAsString`
619619
castInUnion := BuildCastFunction4Union(mock.NewContext(), dg.genColumn(mysql.TypeLonglong, 1), types.NewFieldType(mysql.TypeString))
620620
c.Assert(castInUnion.(*ScalarFunction).Function.implicitParameters(), IsNil)
621-
expr = pc.ExprToPB(sc, castInUnion)
621+
expr = pc.ExprToPB(castInUnion)
622622
c.Assert(expr.Sig, Equals, tipb.ScalarFuncSig_CastIntAsString)
623623
c.Assert(len(expr.Val), Equals, 0)
624624

625625
// InUnion flag is true in `BuildCastFunction4Union` when `ScalarFuncSig_CastStringAsInt`
626626
castInUnion = BuildCastFunction4Union(mock.NewContext(), dg.genColumn(mysql.TypeString, 1), types.NewFieldType(mysql.TypeLonglong))
627627
c.Assert(castInUnion.(*ScalarFunction).Function.implicitParameters(), DeepEquals, []types.Datum{types.NewIntDatum(1)})
628-
expr = pc.ExprToPB(sc, castInUnion)
628+
expr = pc.ExprToPB(castInUnion)
629629
c.Assert(expr.Sig, Equals, tipb.ScalarFuncSig_CastStringAsInt)
630630
c.Assert(len(expr.Val), Greater, 0)
631631
datums, err = codec.Decode(expr.Val, 1)

0 commit comments

Comments
 (0)