Dandandan opened a new issue, #22214:
URL: https://github.com/apache/datafusion/issues/22214

   ### Describe the bug
   
   `date_trunc` can panic during planning/constant folding for lower-bound 
nanosecond timestamps. Truncating to a coarser unit can produce a value outside 
Arrow's nanosecond timestamp range, and the code unwraps `None`.
   
   ### To Reproduce
   
   ```sql
   EXPLAIN SELECT date_trunc('year', TIMESTAMP '1677-09-22 00:00:00');
   ```
   
   ### Actual behavior
   
   ```text
   thread 'main' panicked at 
datafusion/functions/src/datetime/date_trunc.rs:649:14:
   called `Option::unwrap()` on a `None` value
   ```
   
   ### Expected behavior
   
   Return an error or NULL for an out-of-range truncated timestamp; do not 
panic.
   
   ### Notes
   
   Other coarse granularities near the lower nanosecond timestamp bound hit the 
same unwrap.


-- 
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]

Reply via email to