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/05/23 18:42:16 UTC

[GitHub] [arrow] houqp commented on a change in pull request #7253: ARROW-4957: [Rust] [DataFusion] Re-implement get_supertype

houqp commented on a change in pull request #7253:
URL: https://github.com/apache/arrow/pull/7253#discussion_r429568842



##########
File path: rust/datafusion/src/logicalplan.rs
##########
@@ -725,36 +725,47 @@ impl fmt::Debug for LogicalPlan {
 /// Verify a given type cast can be performed
 pub fn can_coerce_from(type_into: &DataType, type_from: &DataType) -> bool {
     use self::DataType::*;
+
+    if type_from == type_into {
+        return true;
+    }
+
     match type_into {
         Int8 => match type_from {
             Int8 => true,
             _ => false,
         },
         Int16 => match type_from {
-            Int8 | Int16 | UInt8 => true,
+            Int8 | Int16 => true,
+            UInt8 => true,
             _ => false,
         },
         Int32 => match type_from {
-            Int8 | Int16 | Int32 | UInt8 | UInt16 => true,
+            Int8 | Int16 | Int32 => true,
+            UInt8 | UInt16 => true,
             _ => false,
         },
         Int64 => match type_from {
-            Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 => true,
+            Int8 | Int16 | Int32 | Int64 => true,
+            UInt8 | UInt16 | UInt32 => true,
             _ => false,
         },
         UInt8 => match type_from {
             UInt8 => true,
             _ => false,
         },
         UInt16 => match type_from {
+            Int8 => true,

Review comment:
       for my own curiosity, what's the expected behavior when a negative int8 is coerced into uint16?




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