zhiqiang-hhhh commented on PR #32518:
URL: https://github.com/apache/doris/pull/32518#issuecomment-2020155914
> @yiguolei @zhiqiang-hhhh
>
> Hi, I added the cast from datetime to decimal. Also, I modified the logic
in `cast_to_decimals()`. However, there is an exception, to test this SQL:
`select cast(a as decimal(30, 9)) from (select cast("9999-12-31 23:59:59.999"
as datetime) a) t1;`
>
> In Doris, it directly get the exception: `Conversion from
Nullable(DateTimeV2) to Decimal(30, 9) is not supported.`
>
> It looks like the cast from string to datetime cannot make sure the
accuracy. Due to this reason, this sql tries to cast a `NULL` to decimal. I
think the continuous problem (**accuracy from string to datetime**) can be
handled in another issue.
You need to specify the scale of micro-second part.
```sql
select cast("9999-12-31 23:59:59.999" as datetime(3))
--------------
+--------------------------------------------------+
| cast('9999-12-31 23:59:59.999' as DATETIMEV2(3)) |
+--------------------------------------------------+
| 9999-12-31 23:59:59.999 |
+--------------------------------------------------+
1 row in set (0.01 sec)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]