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 21:14:40 UTC

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

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



##########
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:
       Thanks, this is actually a bug. The goal of this can_coalesce method is to determine if DataFusion can safely cast from one type to another without any data loss, so it can add implicit casts in queries. This is convenient when the user is comparing two expressions of different types.
   
   Separately from this, users can add any explicit CAST they want to in their query plan.




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