tustvold commented on code in PR #3046:
URL: https://github.com/apache/arrow-rs/pull/3046#discussion_r1017724762
##########
arrow/src/compute/kernels/temporal.rs:
##########
@@ -715,32 +771,46 @@ where
T: ArrowTemporalType + ArrowNumericType,
i64: From<T::Native>,
{
- time_fraction_generic::<T, _, _>(array, "nanosecond", |t| t.nanosecond()
as i32)
+ time_fraction_internal(array, "nanosecond", |t| t.nanosecond() as i32)
+}
+
+/// Extracts the nanoseconds of a given temporal primitive array as an array
of integers.
+/// If the given array isn't temporal primitive or dictionary array,
+/// an `Err` will be returned.
+pub fn nanosecond_dyn(array: &dyn Array) -> Result<ArrayRef> {
+ time_fraction_dyn(array, "nanosecond", |t| t.nanosecond() as i32)
}
/// Extracts the time fraction of a given temporal array as an array of
integers
-fn time_fraction_generic<T, A: ArrayAccessor<Item = T::Native>, F>(
- array: A,
- name: &str,
- op: F,
-) -> Result<Int32Array>
+fn time_fraction_dyn<F>(array: &dyn Array, name: &str, op: F) ->
Result<ArrayRef>
Review Comment:
I wonder if more of the kernels could be implemented using this, possibly
something for a future PR
--
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]