apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.62k stars 3.26k forks source link

[Bug] cast datetime to decimal gets wrong result #32773

Open zhiqiang-hhhh opened 7 months ago

zhiqiang-hhhh commented 7 months ago

Search before asking

Version

master

What's Wrong?

select cast(c as decimal(30,9)) from (select cast("9999-12-31" as datetime) c) t3
--------------

+------------------------------+
| cast(c as DECIMALV3(30, 9))  |
+------------------------------+
| 703674110198153216.000000000 |
+------------------------------+
1 row in set (0.02 sec)

What You Expected?

select cast(c as decimal(30,9)) from (select cast("9999-12-31" as datetime) c) t3

cast(c as decimal(30,9))
99991231000000.000000000

How to Reproduce?

No response

Anything Else?

fix reference https://github.com/apache/doris/pull/32518

this will be an easy task

Are you willing to submit PR?

Code of Conduct

AcKing-Sam commented 7 months ago

@zhiqiang-hhhh I am willing to fix it :)

zhiqiang-hhhh commented 7 months ago

@AcKing-Sam maybe you can combine the fix of datetime to https://github.com/apache/doris/pull/32515

AcKing-Sam commented 7 months ago

@zhiqiang-hhhh Ok, thanks a lot!