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

[release-19.0] evalengine: Ensure to pass down the precision (#15611) #15612

Merged
merged 1 commit into from
Apr 3, 2024
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
4 changes: 4 additions & 0 deletions go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ func TestCompilerSingle(t *testing.T) {
expression: `now() + interval 654321 microsecond`,
result: `DATETIME("2023-10-24 12:00:00.654321")`,
},
{
expression: `1 * unix_timestamp(utc_timestamp(1))`,
result: `DECIMAL(1698134400.1)`,
},
}

tz, _ := time.LoadLocation("Europe/Madrid")
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/fn_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (call *builtinNow) compile(c *compiler) (ctype, error) {
t = sqltypes.Datetime
c.asm.Fn_Now(call.prec, call.utc)
}
return ctype{Type: t, Col: collationBinary}, nil
return ctype{Type: t, Col: collationBinary, Size: int32(call.prec)}, nil
}

func (call *builtinNow) constant() bool {
Expand All @@ -234,7 +234,7 @@ func (call *builtinSysdate) eval(env *ExpressionEnv) (eval, error) {

func (call *builtinSysdate) compile(c *compiler) (ctype, error) {
c.asm.Fn_Sysdate(call.prec)
return ctype{Type: sqltypes.Datetime, Col: collationBinary}, nil
return ctype{Type: sqltypes.Datetime, Col: collationBinary, Size: int32(call.prec)}, nil
}

func (call *builtinSysdate) constant() bool {
Expand Down
Loading