Skip to content

Commit

Permalink
expression: Support push fucntion unix_timestamp, concat down to TiFl…
Browse files Browse the repository at this point in the history
…ash. (#25083)
  • Loading branch information
LittleFall committed Jun 18, 2021
1 parent 179b2e7 commit 5c873e7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ func (s *testEvaluatorSuite) TestExprPushDownToFlash(c *C) {
c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_StrToDateDatetime)
exprs = append(exprs, function)

// ScalarFuncSig_RoundReal
function, err = NewFunction(mock.NewContext(), ast.Round, types.NewFieldType(mysql.TypeDouble), realColumn)
c.Assert(err, IsNil)
exprs = append(exprs, function)
Expand Down Expand Up @@ -801,6 +802,31 @@ func (s *testEvaluatorSuite) TestExprPushDownToFlash(c *C) {
c.Assert(err, IsNil)
exprs = append(exprs, function)

// concat
function, err = NewFunction(mock.NewContext(), ast.Concat, types.NewFieldType(mysql.TypeString), stringColumn, intColumn, realColumn)
c.Assert(err, IsNil)
exprs = append(exprs, function)

// UnixTimestampCurrent
function, err = NewFunction(mock.NewContext(), ast.UnixTimestamp, types.NewFieldType(mysql.TypeLonglong))
c.Assert(err, IsNil)
_, ok := function.(*Constant)
c.Assert(ok, IsTrue)

// UnixTimestampInt
datetimeColumn.RetType.Decimal = 0
function, err = NewFunction(mock.NewContext(), ast.UnixTimestamp, types.NewFieldType(mysql.TypeLonglong), datetimeColumn)
c.Assert(err, IsNil)
c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_UnixTimestampInt)
exprs = append(exprs, function)

// UnixTimestampDecimal
datetimeColumn.RetType.Decimal = types.UnspecifiedLength
function, err = NewFunction(mock.NewContext(), ast.UnixTimestamp, types.NewFieldType(mysql.TypeNewDecimal), datetimeColumn)
c.Assert(err, IsNil)
c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_UnixTimestampDec)
exprs = append(exprs, function)

canPush := CanExprsPushDown(sc, exprs, client, kv.TiFlash)
c.Assert(canPush, Equals, true)

Expand Down

0 comments on commit 5c873e7

Please sign in to comment.