Skip to content

Commit

Permalink
expr: support from_unixtime pushdown to tikv (#58941)
Browse files Browse the repository at this point in the history
close #58940
  • Loading branch information
wshwsh12 authored Jan 24, 2025
1 parent a69f863 commit 4636702
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 10 additions & 0 deletions pkg/expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,16 @@ func TestExprPushDownToTiKV(t *testing.T) {
retType: types.NewFieldType(mysql.TypeString),
args: []Expression{stringColumn, intColumn, NewStrConst("hour")},
},
{
functionName: ast.FromUnixTime,
retType: types.NewFieldType(mysql.TypeDatetime),
args: []Expression{decimalColumn},
},
{
functionName: ast.FromUnixTime,
retType: types.NewFieldType(mysql.TypeString),
args: []Expression{decimalColumn, stringColumn},
},
}

ctx = mock.NewContext()
Expand Down
4 changes: 2 additions & 2 deletions pkg/expression/infer_pushdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func scalarExprSupportedByTiKV(ctx EvalContext, sf *ScalarFunction) bool {
ast.Hour, ast.Minute, ast.Second, ast.MicroSecond, ast.Month,
/* 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.FromDays, /* ast.ToDays */
ast.PeriodAdd, ast.PeriodDiff /*ast.TimestampDiff, ast.DateAdd*/, ast.FromUnixTime,
/* ast.LastDay */
ast.Sysdate,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ explain format = 'brief' select * from t t1 left join t t2 on t1.a=t2.a where fr
id estRows task access object operator info
Projection 9990.00 root planner__core__casetest__integration.t.a, planner__core__casetest__integration.t.b, planner__core__casetest__integration.t.a, planner__core__casetest__integration.t.b
└─HashJoin 9990.00 root inner join, equal:[eq(planner__core__casetest__integration.t.a, planner__core__casetest__integration.t.a)]
├─Selection(Build) 7992.00 root from_unixtime(cast(planner__core__casetest__integration.t.b, decimal(20,0) BINARY))
│ └─TableReader 9990.00 root data:Selection
│ └─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__integration.t.a))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
├─TableReader(Build) 7992.00 root data:Selection
│ └─Selection 7992.00 cop[tikv] from_unixtime(cast(planner__core__casetest__integration.t.b, decimal(20,0) BINARY)), not(isnull(planner__core__casetest__integration.t.a))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 9990.00 root data:Selection
└─Selection 9990.00 cop[tikv] not(isnull(planner__core__casetest__integration.t.a))
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
Expand Down

0 comments on commit 4636702

Please sign in to comment.