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 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
14 changes: 11 additions & 3 deletions expression/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,22 @@
switch x := v.(type) {
case string:
lowerX := strings.ToLower(x)
if lowerX == ast.CurrentTimestamp || lowerX == ast.CurrentDate {
switch lowerX {
case ast.CurrentTimestamp:
if value, err = getTimeCurrentTimeStamp(ctx, tp, fsp); err != nil {
return d, err
}
} else if lowerX == types.ZeroDatetimeStr {
case ast.CurrentDate:
if value, err = getTimeCurrentTimeStamp(ctx, tp, fsp); err != nil {
return d, err
}

Check warning on line 105 in expression/helper.go

View check run for this annotation

Codecov / codecov/patch

expression/helper.go#L104-L105

Added lines #L104 - L105 were not covered by tests
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(sc, 0, tp, fsp)
terror.Log(err)
} else {
default:
value, err = types.ParseTime(sc, x, tp, fsp, explicitTz)
if err != nil {
return d, err
Expand Down