Skip to content

Commit

Permalink
expression: support str_to_date push to TiFlash (#25095) (#25148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jun 18, 2021
1 parent 2c4be62 commit 4c5046f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ func (s *testEvaluatorSuite) TestExprPushDownToFlash(c *C) {
c.Assert(err, IsNil)
exprs = append(exprs, function)

// StrToDateDateTime
function, err = NewFunction(mock.NewContext(), ast.StrToDate, types.NewFieldType(mysql.TypeDatetime), stringColumn, stringColumn)
c.Assert(err, IsNil)
c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_StrToDateDatetime)
exprs = append(exprs, function)

function, err = NewFunction(mock.NewContext(), ast.Round, types.NewFieldType(mysql.TypeDouble), realColumn)
c.Assert(err, IsNil)
exprs = append(exprs, function)
Expand Down
9 changes: 9 additions & 0 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,15 @@ func scalarExprSupportedByFlash(function *ScalarFunction) bool {
case tipb.ScalarFuncSig_ExtractDatetime:
return true
}
case ast.StrToDate:
switch function.Function.PbCode() {
case
tipb.ScalarFuncSig_StrToDateDate,
tipb.ScalarFuncSig_StrToDateDatetime:
return true
default:
return false
}
}
return false
}
Expand Down

0 comments on commit 4c5046f

Please sign in to comment.