From 70c4d99c817d038c5cc87dbb583589c91ec8a404 Mon Sep 17 00:00:00 2001 From: Zhi Qi Date: Wed, 20 Apr 2022 21:53:14 +0800 Subject: [PATCH] support fromdays and todays push down to tiflash --- expression/expr_to_pb_test.go | 10 ++++++++++ expression/expression.go | 1 + 2 files changed, 11 insertions(+) diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index 4a509c698066a..610e690ae5a6e 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -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) diff --git a/expression/expression.go b/expression/expression.go index 20dba5699e7ea..d9e4adf87595f 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -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.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,