liukun4515 commented on a change in pull request #1554:
URL: https://github.com/apache/arrow-datafusion/pull/1554#discussion_r786079635



##########
File path: datafusion/src/physical_plan/coercion_rule/binary_rule.rs
##########
@@ -162,12 +162,141 @@ fn get_comparison_common_decimal_type(
     }
 }
 
+// Convert the numeric data type to the decimal data type.
+// Now, we just support the signed integer type and floating-point type.
+fn convert_numeric_type_to_decimal(numeric_type: &DataType) -> 
Option<DataType> {
+    match numeric_type {
+        DataType::Int8 => Some(DataType::Decimal(3, 0)),
+        DataType::Int16 => Some(DataType::Decimal(5, 0)),
+        DataType::Int32 => Some(DataType::Decimal(10, 0)),
+        DataType::Int64 => Some(DataType::Decimal(20, 0)),
+        // TODO if we convert the floating-point data to the decimal type, it 
maybe overflow.
+        DataType::Float32 => Some(DataType::Decimal(14, 7)),
+        DataType::Float64 => Some(DataType::Decimal(30, 15)),
+        _ => None,
+    }
+}
+
+fn mathematics_numerical_coercion(

Review comment:
       
![image](https://user-images.githubusercontent.com/7450163/149791191-ed11a0f5-8794-44b7-a695-b83b82e9fb3c.png)
   The `numerical_coercion` is used by other coercion functions:
   1. `numerical_coercion`->`eq_coercion`  -> `Operator::IsDistinctFrom | 
Operator::IsNotDistinctFrom => `
   2. `numerical_coercion` -> `dictionary_value_coercion`
   If I extend the `numerical_coercion`, it may take a side effect to other 
coercion logical.
   I will refactor and merge these two together and make it clear if there is 
no conflict.
   @alamb 




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