Kristofferjoha commented on issue #26673: URL: https://github.com/apache/datafusion/issues/26673#issuecomment-6371290781
> 5\. Thanks [@alamb](https://github.com/alamb) for filing this. The cutoff is 2.147483647 seconds, which is `i32::MAX` nanoseconds. That matches your cases (2.10 keeps its fraction, 2.50 loses it): > SELECT d, EXTRACT(EPOCH FROM d) AS epoch > FROM (VALUES > (arrow_cast(2147483647, 'Duration(ns)')), > (arrow_cast(2147483648, 'Duration(ns)')) > ) AS v(d); > > > > > > > > > > ``` > | 0 days 0 hours 0 mins 2.147483647 secs | 2.147483647 | > | 0 days 0 hours 0 mins 2.147483648 secs | 2.0 | > ``` > > > > > > > > > > > > As I read it, [`epoch`](https://github.com/apache/datafusion/blob/c76ed5396ad3f4a4dc9d9ceeddc419a146b871f9/datafusion/functions/src/datetime/date_part.rs#L592) sends `Duration` to [`seconds`](https://github.com/apache/datafusion/blob/c76ed5396ad3f4a4dc9d9ceeddc419a146b871f9/datafusion/functions/src/datetime/date_part.rs#L512-L524), which reads `date_part(array, Nanosecond)` as an `Int32` array. For a `Duration(ns)`, arrow-rs returns the total nanoseconds with [`try_into().ok()`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-arith/src/temporal.rs#L774), so the value is NULL above `i32::MAX`. `seconds` treats a NULL sub-second part as zero. I have not stepped through it in a debugger. This looks like the same `Int32` overflow on `Duration` as [#14738](https://github.com/apache/datafusion/issues/14738). > `EXTRACT(EPOCH FROM INTERVAL '4.322 seconds')` returns `4.322`, so only the `Duration` path is affected. The same happens for `Duration(µs)` and `Duration(ms)` inputs. Trying to unassign myself, seems like you have it figured out -- 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]
