Skip to content

Different result of decimal to timestamp cast when source value is constant #16531

@findepi

Description

@findepi

Describe the bug

decimal value V cast to timestamp type produces different values T1 or T2, depending on whether V is a constant

To Reproduce

> SELECT CAST(CAST(1 AS decimal(17,2)) AS timestamp(3));
+---------------------+
| Int64(1)            |
+---------------------+
| 1970-01-01T00:00:01 |
+---------------------+
1 row(s) fetched.
Elapsed 0.003 seconds.

> SELECT CAST(CAST(x AS decimal(17,2)) AS timestamp(3)) from (values (1)) t(x);
+-------------------------+
| t.x                     |
+-------------------------+
| 1970-01-01T00:00:00.001 |
+-------------------------+

Expected behavior

The queries should produce same result

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions