You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/02 08:15:18 UTC

[GitHub] [arrow-rs] waitingkuo commented on a diff in pull request #2996: `arrow::compute::kernels::temporal` should support nanoseconds

waitingkuo commented on code in PR #2996:
URL: https://github.com/apache/arrow-rs/pull/2996#discussion_r1011348242


##########
arrow/src/compute/kernels/temporal.rs:
##########
@@ -717,49 +717,65 @@ where
     T: ArrowTemporalType + ArrowNumericType,
     i64: From<T::Native>,
 {
-    second_generic::<T, _>(array)
+    second_fraction_generic::<T, _, _>(array, "second", |t| t.second() as i32)
 }
 
-/// Extracts the seconds of a given temporal array as an array of integers
-pub fn second_generic<T, A: ArrayAccessor<Item = T::Native>>(
+/// Extracts the nanoseconds of a given temporal primitive array as an array of integers
+pub fn nanosecond<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
+where
+    T: ArrowTemporalType + ArrowNumericType,
+    i64: From<T::Native>,
+{
+    second_fraction_generic::<T, _, _>(array, "nanosecond", |t| t.nanosecond() as i32)
+}
+
+/// Extracts the seconds fraction of a given temporal array as an array of integers
+pub fn second_fraction_generic<T, A: ArrayAccessor<Item = T::Native>, F>(

Review Comment:
   i suggest that we could either
   1. separate them (aka second_generic, and nano_generic), keep it consistent wither other operator
   2. make it more general, combines not only second, nanosecond. (e.g. `second_fraction_generic::<T, _, _>(array, "minute", |t| t.minute() as i32` should work for `minute`) 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org