alamb commented on code in PR #3549:
URL: https://github.com/apache/arrow-datafusion/pull/3549#discussion_r976838532
##########
datafusion/expr/src/binary_rule.rs:
##########
@@ -624,19 +627,12 @@ fn eq_coercion(lhs_type: &DataType, rhs_type: &DataType)
-> Option<DataType> {
}
/// coercion rules from NULL type. Since NULL can be casted to most of types
in arrow,
-/// either lhs or rhs is NULL, if NULL can be casted to type of the other
side, the coecion is valid.
+/// either lhs or rhs is NULL, if NULL can be casted to type of the other
side, the coercion is valid.
fn null_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
{
match (lhs_type, rhs_type) {
- (DataType::Null, _) => {
- if can_cast_types(&DataType::Null, rhs_type) {
- Some(rhs_type.clone())
- } else {
- None
- }
- }
- (_, DataType::Null) => {
- if can_cast_types(&DataType::Null, lhs_type) {
- Some(lhs_type.clone())
+ (DataType::Null, other_type) | (other_type, DataType::Null) => {
Review Comment:
this is a nice cleanup
##########
datafusion/expr/src/binary_rule.rs:
##########
@@ -308,25 +308,18 @@ fn mathematics_numerical_coercion(
(Decimal128(_, _), Decimal128(_, _)) => {
coercion_decimal_mathematics_type(mathematics_op, lhs_type,
rhs_type)
}
- (Decimal128(_, _), _) => {
- let converted_decimal_type =
coerce_numeric_type_to_decimal(rhs_type);
- match converted_decimal_type {
- None => None,
- Some(right_decimal_type) => coercion_decimal_mathematics_type(
- mathematics_op,
- lhs_type,
- &right_decimal_type,
- ),
- }
+ (Null, dec_type @ Decimal128(_, _)) | (dec_type @ Decimal128(_, _),
Null) => {
+ Some(dec_type.clone())
Review Comment:
Could the same coercion (Null to that type) be applied for all the other
numeric types as well?
In other words, I wonder if we need to special case Decimal128 ? Is it to
skip the special decimal coercion logic below?
--
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]