Skip to content

Commit

Permalink
expression: support functions fromdays and todays push down to ti…
Browse files Browse the repository at this point in the history
…flash (#34135)

close #34136
  • Loading branch information
LittleFall authored May 18, 2022
1 parent d2c4339 commit 4a2a2db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,16 @@ func TestExprPushDownToFlash(t *testing.T) {
require.Equal(t, tipb.ScalarFuncSig_ConcatWS, function.(*ScalarFunction).Function.PbCode())
exprs = append(exprs, function)

function, err = NewFunction(mock.NewContext(), ast.FromDays, types.NewFieldType(mysql.TypeDate), intColumn)
require.NoError(t, err)
require.Equal(t, tipb.ScalarFuncSig_FromDays, function.(*ScalarFunction).Function.PbCode())
exprs = append(exprs, function)

function, err = NewFunction(mock.NewContext(), ast.ToDays, types.NewFieldType(mysql.TypeLonglong), datetimeColumn)
require.NoError(t, err)
require.Equal(t, tipb.ScalarFuncSig_ToDays, function.(*ScalarFunction).Function.PbCode())
exprs = append(exprs, function)

// StrToDateDateTime
function, err = NewFunction(mock.NewContext(), ast.StrToDate, types.NewFieldType(mysql.TypeDatetime), stringColumn, stringColumn)
require.NoError(t, err)
Expand Down Expand Up @@ -1368,7 +1378,7 @@ func TestExprOnlyPushDownToTiKV(t *testing.T) {
sc := new(stmtctx.StatementContext)
client := new(mock.Client)

function, err := NewFunction(mock.NewContext(), "from_days", types.NewFieldType(mysql.TypeLonglong), genColumn(mysql.TypeDatetime, 1))
function, err := NewFunction(mock.NewContext(), "uuid", types.NewFieldType(mysql.TypeLonglong))
require.NoError(t, err)
var exprs = make([]Expression, 0)
exprs = append(exprs, function)
Expand Down
1 change: 1 addition & 0 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ func scalarExprSupportedByFlash(function *ScalarFunction) bool {
ast.Date, ast.Year, ast.Month, ast.Day, ast.Quarter, ast.DayName, ast.MonthName,
ast.DateDiff, ast.TimestampDiff, ast.DateFormat, ast.FromUnixTime,
ast.DayOfWeek, ast.DayOfMonth, ast.DayOfYear, ast.LastDay, ast.WeekOfYear, ast.ToSeconds,
ast.FromDays, ast.ToDays,

ast.Sqrt, ast.Log, ast.Log2, ast.Log10, ast.Ln, ast.Exp, ast.Pow, ast.Sign,
ast.Radians, ast.Degrees, ast.Conv, ast.CRC32,
Expand Down

0 comments on commit 4a2a2db

Please sign in to comment.