alamb commented on code in PR #5342:
URL: https://github.com/apache/arrow-datafusion/pull/5342#discussion_r1118079876


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -238,13 +238,32 @@ fn comparison_binary_numeric_coercion(
         (_, Decimal128(_, _)) => get_comparison_common_decimal_type(rhs_type, 
lhs_type),
         (Float64, _) | (_, Float64) => Some(Float64),
         (_, Float32) | (Float32, _) => Some(Float32),
-        (Int64, _) | (_, Int64) => Some(Int64),
-        (Int32, _) | (_, Int32) => Some(Int32),
-        (Int16, _) | (_, Int16) => Some(Int16),
-        (Int8, _) | (_, Int8) => Some(Int8),
+        // start checking from Int64, that is the most inclusive integer type

Review Comment:
   Likewise I think the same pattern could be used for `UInt*` variants



##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -238,13 +238,32 @@ fn comparison_binary_numeric_coercion(
         (_, Decimal128(_, _)) => get_comparison_common_decimal_type(rhs_type, 
lhs_type),
         (Float64, _) | (_, Float64) => Some(Float64),
         (_, Float32) | (Float32, _) => Some(Float32),
-        (Int64, _) | (_, Int64) => Some(Int64),
-        (Int32, _) | (_, Int32) => Some(Int32),
-        (Int16, _) | (_, Int16) => Some(Int16),
-        (Int8, _) | (_, Int8) => Some(Int8),
+        // start checking from Int64, that is the most inclusive integer type
+        (Int64, _)
+        | (_, Int64)
+        | (UInt64, Int8)
+        | (Int8, UInt64)
+        | (UInt64, Int16)
+        | (Int16, UInt64)
+        | (UInt64, Int32)
+        | (Int32, UInt64)
+        | (UInt32, Int8)
+        | (Int8, UInt32)
+        | (UInt32, Int16)
+        | (Int16, UInt32)
+        | (UInt32, Int32)
+        | (Int32, UInt32) => Some(Int64),
         (UInt64, _) | (_, UInt64) => Some(UInt64),
+        (Int32, _)
+        | (_, Int32)

Review Comment:
   If one of the arguments is Int32, doesn't that mean the output should be 
Int64? 
   (as in `(_, Int32)` should not be in the same match arm.



##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -238,13 +238,32 @@ fn comparison_binary_numeric_coercion(
         (_, Decimal128(_, _)) => get_comparison_common_decimal_type(rhs_type, 
lhs_type),
         (Float64, _) | (_, Float64) => Some(Float64),
         (_, Float32) | (Float32, _) => Some(Float32),
-        (Int64, _) | (_, Int64) => Some(Int64),
-        (Int32, _) | (_, Int32) => Some(Int32),
-        (Int16, _) | (_, Int16) => Some(Int16),
-        (Int8, _) | (_, Int8) => Some(Int8),
+        // start checking from Int64, that is the most inclusive integer type

Review Comment:
   Could we express the same logic more concisely with something like:
   
   ```
         (Int64, _) | (_, Int64) => Some(Int64),
           (Int32, _) | (_, Int32) => Some(Int64),
           (Int16, _) | (_, Int16) => Some(Int32),
           (Int8, _) | (_, Int8) => Some(Int16),
   ```



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