Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expr: support from_unixtime pushdown to tikv #58941

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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