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 2020/10/14 14:27:54 UTC

[GitHub] [arrow] alamb commented on a change in pull request #8460: ARROW-10236: [Rust] Add can_cast_types to arrow cast kernel, use in DataFusion

alamb commented on a change in pull request #8460:
URL: https://github.com/apache/arrow/pull/8460#discussion_r504721964



##########
File path: rust/arrow/src/compute/kernels/cast.rs
##########
@@ -356,11 +520,24 @@ pub fn cast(array: &ArrayRef, to_type: &DataType) -> Result<ArrayRef> {
 
         // temporal casts
         (Int32, Date32(_)) => cast_array_data::<Date32Type>(array, to_type.clone()),
-        (Int32, Time32(_)) => cast_array_data::<Date32Type>(array, to_type.clone()),
+        (Int32, Time32(TimeUnit::Second)) => {

Review comment:
       It is not possible to cast Int32 to a Time32(Microsecond) or Time32(Nanosecond)

##########
File path: rust/arrow/src/compute/kernels/cast.rs
##########
@@ -549,7 +726,18 @@ pub fn cast(array: &ArrayRef, to_type: &DataType) -> Result<ArrayRef> {
         (Timestamp(from_unit, _), Date64(_)) => {
             let from_size = time_unit_multiple(&from_unit);
             let to_size = MILLISECONDS;
-            if from_size != to_size {
+
+            // Scale time_array by (to_size / from_size) using a

Review comment:
       Without this code, casting from a timestamp 32 -> Date64 would result in a divide by zero error (as `from_size / to_size` was `1 / 1000 == 0`

##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -1129,6 +1129,16 @@ impl DataType {
             DataType::Dictionary(_, _) => json!({ "name": "dictionary"}),
         }
     }
+
+    /// Returns true if this type is numeric: (UInt*, Unit*, or Float*)
+    pub fn is_numeric(t: &DataType) -> bool {

Review comment:
       As suggested by @nevi-me on https://github.com/apache/arrow/pull/8400#discussion_r501851945




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

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