Dandandan opened a new issue, #22209:
URL: https://github.com/apache/datafusion/issues/22209
### Describe the bug
`date_trunc` can panic during planning/constant folding for extreme
non-nanosecond timestamps. The value is multiplied while converting to
nanoseconds without checking for overflow.
### To Reproduce
```sql
EXPLAIN SELECT date_trunc(
'hour',
arrow_cast(9223372036854775807, 'Timestamp(Second, None)')
);
```
### Actual behavior
```text
thread 'main' panicked at
datafusion/functions/src/datetime/date_trunc.rs:721:47:
attempt to multiply with overflow
```
### Expected behavior
Return a planning error for an out-of-range timestamp conversion instead of
panicking.
### Notes
The panic is reachable from SQL through `arrow_cast` plus `date_trunc`;
similar extreme `Timestamp(Millisecond)` or `Timestamp(Microsecond)` values
appear to hit the same unchecked scale conversion.
--
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]