Skip to content
Snippets Groups Projects
Unverified Commit 30e722a2 authored by ou yuanning's avatar ou yuanning Committed by GitHub
Browse files

Improve date function (#2767)

parent 4808d92f
No related branches found
No related tags found
No related merge requests found
......@@ -241,6 +241,20 @@ func resetIntervalFunctionExprs(dateExpr *Expr, intervalExpr *Expr) ([]*Expr, er
return nil, err
}
// rewrite "date '2020-10-10' - interval 1 Hour" to date_add(datetime, 1, hour)
if dateExpr.Typ.Id == plan.Type_DATE {
switch returnType {
case types.Day, types.Week, types.Month, types.Quarter, types.Year:
default:
dateExpr, err = appendCastExpr(dateExpr, &plan.Type{
Id: plan.Type_DATETIME,
Size: 8,
})
if err != nil {
return nil, err
}
}
}
return []*Expr{
dateExpr,
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment