Skip to content

Commit

Permalink
expr: fix copr-test (pingcap#32740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer authored Mar 2, 2022
1 parent f6a32ce commit bbe2d00
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
10 changes: 5 additions & 5 deletions cmd/explaintest/r/index_merge.result
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ c1 c2 c3 c4 c5
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and truncate(c1, 1) = 1 order by 1;
id estRows task access object operator info
Sort_5 4433.77 root test.t1.c1
└─IndexMerge_12 4433.77 root
├─IndexRangeScan_8(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_9(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_11(Probe) 4433.77 cop[tikv] eq(truncate(test.t1.c1, 1), 1)
└─TableRowIDScan_10 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
└─Selection_8 4433.77 root eq(truncate(test.t1.c1, 1), 1)
└─IndexMerge_12 5542.21 root
├─IndexRangeScan_9(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_10(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─TableRowIDScan_11(Probe) 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and truncate(c1, 1) = 1 order by 1;
c1 c2 c3 c4 c5
1 1 1 1 1
Expand Down
4 changes: 4 additions & 0 deletions expression/distsql_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ func getSignatureByPB(ctx sessionctx.Context, sigCode tipb.ScalarFuncSig, tp *ti
f = &builtinGreatestCmpStringAsTimeSig{base, false}
case tipb.ScalarFuncSig_GreatestCmpStringAsDate:
f = &builtinGreatestCmpStringAsTimeSig{base, true}
case tipb.ScalarFuncSig_GreatestDuration:
f = &builtinGreatestDurationSig{base}
case tipb.ScalarFuncSig_LeastInt:
f = &builtinLeastIntSig{base}
case tipb.ScalarFuncSig_LeastReal:
Expand All @@ -245,6 +247,8 @@ func getSignatureByPB(ctx sessionctx.Context, sigCode tipb.ScalarFuncSig, tp *ti
f = &builtinLeastCmpStringAsTimeSig{base, false}
case tipb.ScalarFuncSig_LeastCmpStringAsDate:
f = &builtinLeastCmpStringAsTimeSig{base, true}
case tipb.ScalarFuncSig_LeastDuration:
f = &builtinLeastDurationSig{base}
case tipb.ScalarFuncSig_IntervalInt:
f = &builtinIntervalIntSig{base, false} // Since interval function won't be pushed down to TiKV, therefore it doesn't matter what value we give to hasNullable
case tipb.ScalarFuncSig_IntervalReal:
Expand Down
10 changes: 5 additions & 5 deletions expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1263,11 +1263,11 @@ func TestExprPushDownToTiKV(t *testing.T) {
retType: types.NewFieldType(mysql.TypeDouble),
args: []Expression{intColumn},
},
{
functionName: ast.Truncate,
retType: types.NewFieldType(mysql.TypeDouble),
args: []Expression{intColumn, intColumn},
},
//{
// functionName: ast.Truncate,
// retType: types.NewFieldType(mysql.TypeDouble),
// args: []Expression{intColumn, intColumn},
//},
{
functionName: ast.Bin,
retType: types.NewFieldType(mysql.TypeString),
Expand Down
6 changes: 3 additions & 3 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ func scalarExprSupportedByTiKV(sf *ScalarFunction) bool {
ast.Greatest, ast.Least, /* ast.Interval */

// arithmetical functions.
ast.PI, ast.Truncate,
ast.PI, /* ast.Truncate */
ast.Plus, ast.Minus, ast.Mul, ast.Div, ast.Abs, ast.Mod,

// math functions.
Expand Down Expand Up @@ -989,11 +989,11 @@ func scalarExprSupportedByTiKV(sf *ScalarFunction) bool {
ast.MonthName, ast.MakeDate, ast.TimeToSec, ast.MakeTime,
ast.DateFormat,
ast.Hour, ast.Minute, ast.Second, ast.MicroSecond, ast.Month,
ast.DayName, ast.DayOfMonth, ast.DayOfWeek, ast.DayOfYear,
/* ast.DayName */ ast.DayOfMonth, ast.DayOfWeek, ast.DayOfYear,
ast.Weekday, ast.WeekOfYear, ast.Year,
ast.FromDays, ast.ToDays,
ast.PeriodAdd, ast.PeriodDiff, /*ast.TimestampDiff, ast.DateAdd, ast.FromUnixTime,*/
ast.LastDay,
/* ast.LastDay */
ast.Sysdate,

// encryption functions.
Expand Down
18 changes: 9 additions & 9 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,9 +2778,9 @@ func TestScalarFunctionPushDown(t *testing.T) {
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where month(d);").
CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "dayname(test.t.d)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where dayname(d);").
CheckAt([]int{0, 3, 6}, rows)
//rows[1][2] = "dayname(test.t.d)"
//tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where dayname(d);").
// CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "dayofmonth(test.t.d)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where dayofmonth(d);").
Expand All @@ -2802,17 +2802,17 @@ func TestScalarFunctionPushDown(t *testing.T) {
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where to_days(d);").
CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "last_day(test.t.d)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where last_day(d);").
CheckAt([]int{0, 3, 6}, rows)
//rows[1][2] = "last_day(test.t.d)"
//tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where last_day(d);").
// CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "gt(4, test.t.id)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where pi() > id;").
CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "truncate(test.t.id, 0)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where truncate(id,0)").
CheckAt([]int{0, 3, 6}, rows)
//rows[1][2] = "truncate(test.t.id, 0)"
//tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where truncate(id,0)").
// CheckAt([]int{0, 3, 6}, rows)

rows[1][2] = "bin(test.t.id)"
tk.MustQuery("explain analyze select /*+read_from_storage(tikv[t])*/ * from t where bin(id)").
Expand Down

0 comments on commit bbe2d00

Please sign in to comment.