Skip to content

Commit

Permalink
expression: support pushdown dayofweek and dayofyear to tiflash (#33131)
Browse files Browse the repository at this point in the history
close #33130
  • Loading branch information
gengliqi committed Mar 16, 2022
1 parent 128dc16 commit 80ca342
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,11 +1083,21 @@ func TestExprPushDownToFlash(t *testing.T) {
require.NoError(t, err)
exprs = append(exprs, function)

// DayOfWeek
function, err = NewFunction(mock.NewContext(), ast.DayOfWeek, types.NewFieldType(mysql.TypeDatetime), datetimeColumn)
require.NoError(t, err)
exprs = append(exprs, function)

// DayOfMonth
function, err = NewFunction(mock.NewContext(), ast.DayOfMonth, types.NewFieldType(mysql.TypeDatetime), datetimeColumn)
require.NoError(t, err)
exprs = append(exprs, function)

// DayOfYear
function, err = NewFunction(mock.NewContext(), ast.DayOfYear, types.NewFieldType(mysql.TypeDatetime), datetimeColumn)
require.NoError(t, err)
exprs = append(exprs, function)

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

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

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 80ca342

Please sign in to comment.