mbutrovich commented on code in PR #12422:
URL: https://github.com/apache/arrow-rs/pull/12422#discussion_r4670030006


##########
arrow-cast/src/cast/mod.rs:
##########
@@ -2025,6 +2019,18 @@ const fn units_per_day<T: ArrowTimestampType>() -> i64 {
     SECONDS_IN_DAY * time_unit_multiple(&T::UNIT)
 }
 
+/// Divides every value of `array` by `ratio`, the ratio of a finer time unit 
to a coarser one
+fn div_by_unit_ratio(array: &Int64Array, ratio: i64) -> Int64Array {
+    // A constant divisor lets the compiler replace each division with a 
multiply and shifts.
+    // The ratio of two time units is always one of these three
+    match ratio {
+        1_000 => array.unary(|o| o / 1_000),

Review Comment:
   I originally had these match on the constants defined (MILLISECONDS) etc. 
but that seemed less intuitive since the type is i64 not an enum or anything, 
and this somehow looks more readable to me.



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

Reply via email to