alamb commented on code in PR #26676:
URL: https://github.com/apache/datafusion/pull/26676#discussion_r4363507036
##########
datafusion/functions/src/datetime/date_part.rs:
##########
@@ -589,7 +549,16 @@ fn epoch(array: &dyn Array) -> Result<ArrayRef> {
+ x.nanoseconds as f64 / 1_000_000_000_f64
})
}
- Duration(_) => return seconds(array, Second),
+ Duration(Second) => as_duration_second_array(array)?.unary(|x| x as
f64),
+ Duration(Millisecond) => {
+ as_duration_millisecond_array(array)?.unary(|x| x as f64 /
1_000_f64)
Review Comment:
that certainly looks much faster and simpler
##########
datafusion/sqllogictest/test_files/datetime/date_part.slt:
##########
@@ -1178,6 +1178,63 @@ SELECT extract(epoch from arrow_cast(2,
'Duration(Second)'))
----
2
+# epoch keeps the fraction of a duration whose total sub-second units exceed
i32::MAX
+query RR
+SELECT extract(epoch from arrow_cast(2147483647, 'Duration(Nanosecond)')),
+ extract(epoch from arrow_cast(2147483648, 'Duration(Nanosecond)'))
+----
+2.147483647 2.147483648
+
+query R
+SELECT extract(epoch from timestamp '2025-01-01 00:00:12.923350' - timestamp
'2025-01-01 00:00:00')
Review Comment:
can we add a few more cases here -- perhaps from the issue that was filed? I
think it was clearer then what the expected behavior was and what was being
tested and that it was important to be consistent across fractional values
--
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]