houqp commented on a change in pull request #7253:
URL: https://github.com/apache/arrow/pull/7253#discussion_r429575153
##########
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:
looking at the code, looks like it will return null for negative values.
if that's the case, we should be able to support conversion from signed to
unsigned with the same width as well right?
----------------------------------------------------------------
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:
[email protected]