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

expression: truncate time part for current_date columns (#54045) #56890

Merged
Merged
Changes from 1 commit
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
Next Next commit
This is an automated cherry-pick of #54045
Signed-off-by: ti-chi-bot <[email protected]>
tangenta authored and ti-chi-bot committed Oct 28, 2024
commit 01ef30cb0efa9f7263bc7d72f7de92951dfe7744
20 changes: 20 additions & 0 deletions expression/helper.go
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, expli
switch x := v.(type) {
case string:
lowerX := strings.ToLower(x)
<<<<<<< HEAD:expression/helper.go
if lowerX == ast.CurrentTimestamp || lowerX == ast.CurrentDate {
if value, err = getTimeCurrentTimeStamp(ctx, tp, fsp); err != nil {
return d, err
@@ -103,6 +104,25 @@ func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int, expli
terror.Log(err)
} else {
value, err = types.ParseTime(sc, x, tp, fsp, explicitTz)
=======
switch lowerX {
case ast.CurrentTimestamp:
if value, err = getTimeCurrentTimeStamp(ctx.GetEvalCtx(), tp, fsp); err != nil {
return d, err
}
case ast.CurrentDate:
if value, err = getTimeCurrentTimeStamp(ctx.GetEvalCtx(), tp, fsp); err != nil {
return d, err
}
yy, mm, dd := value.Year(), value.Month(), value.Day()
truncated := types.FromDate(yy, mm, dd, 0, 0, 0, 0)
value.SetCoreTime(truncated)
case types.ZeroDatetimeStr:
value, err = types.ParseTimeFromNum(tc, 0, tp, fsp)
terror.Log(err)
default:
value, err = types.ParseTime(tc, x, tp, fsp)
>>>>>>> 4d8e1d5e485 (expression: truncate time part for current_date columns (#54045)):pkg/expression/helper.go
if err != nil {
return d, err
}
2,154 changes: 2,154 additions & 0 deletions tests/integrationtest/r/executor/write.result

Large diffs are not rendered by default.

1,357 changes: 1,357 additions & 0 deletions tests/integrationtest/t/executor/write.test

Large diffs are not rendered by default.