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/10/06 19:07:36 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2835: Validate ArrayData type when converting to Array (#2834)

tustvold commented on code in PR #2835:
URL: https://github.com/apache/arrow-rs/pull/2835#discussion_r989394060


##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1241,14 +1241,14 @@ pub fn cast_with_options(
         }
         //(Time32(TimeUnit::Second), Time64(_)) => {},
         (Time32(from_unit), Time64(to_unit)) => {
-            let time_array = Int32Array::from(array.data().clone());
+            let array = cast_with_options(array, &Int32, cast_options)?;
+            let time_array = as_primitive_array::<Int32Type>(array.as_ref());
             // note: (numeric_cast + SIMD multiply) is faster than (cast & multiply)
             let c: Int64Array = numeric_cast(&time_array);
             let from_size = time_unit_multiple(from_unit);
             let to_size = time_unit_multiple(to_unit);
             // from is only smaller than to if 64milli/64second don't exist
-            let mult = Int64Array::from(vec![to_size / from_size; array.len()]);
-            let converted = multiply(&c, &mult)?;
+            let converted = multiply_scalar(&c, to_size / from_size)?;

Review Comment:
   Drive by cleanup



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