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

   ### Describe the bug
   
   ```sql
   SELECT extract(nanosecond from arrow_cast(1500000000, 
'Duration(Nanosecond)')),
          extract(nanosecond from interval '1.5 seconds'),
          extract(microsecond from interval '1.5 seconds');
   -- 2500000000, 2500000000, 1500000
   ```
   
   ### Expected behavior
   
   1500000000 for both, consistent with `microsecond`.
   
   ### Additional context
   
   
[`seconds_ns`](https://github.com/apache/datafusion/blob/6bb92bb3f2790ed6fdffadea2965ca473fdba501/datafusion/functions/src/datetime/date_part.rs#L616-L634)
 returns `secs * 1_000_000_000 + subsecs`. For `Duration` and `Interval`, 
`date_part(Nanosecond)` already includes the whole seconds. `seconds_as_i32` 
takes `subsecs % 1_000_000_000`, and `seconds_ns` doesn't. This has been there 
since #20674 (54.0.0). Past `i32::MAX` nanoseconds the NULL-as-zero branch also 
drops the fraction, so `interval '62.5 seconds'` gives 2000000000, the `Int32` 
overflow in #14738.
   
   #26676 fixes `EXTRACT(EPOCH)` on `Duration` by computing from the `i64` 
value, and #19807 fixed it on `Interval` from the interval fields. The same 
approach fits here.
   
   Part of #26672.
   


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