jackwener commented on code in PR #5932:
URL: https://github.com/apache/arrow-datafusion/pull/5932#discussion_r1161439193


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -217,57 +217,61 @@ pub fn temporal_add_sub_coercion(
     lhs_type: &DataType,
     rhs_type: &DataType,
     op: &Operator,
-) -> Result<Option<DataType>> {
+) -> Option<DataType> {
     match (lhs_type, rhs_type, op) {
         // if an interval is being added/subtracted from a date/timestamp, 
return the date/timestamp data type
         (lhs, rhs, _) if is_interval(lhs) && (is_date(rhs) || 
is_timestamp(rhs)) => {
-            Ok(Some(rhs.clone()))
+            Some(rhs.clone())
         }
         (lhs, rhs, _) if is_interval(rhs) && (is_date(lhs) || 
is_timestamp(lhs)) => {
-            Ok(Some(lhs.clone()))
+            Some(lhs.clone())
         }
         // if two timestamps are being subtracted, check their time units and 
return the corresponding interval data type
         (lhs, rhs, Operator::Minus) if is_timestamp(lhs) && is_timestamp(rhs) 
=> {
             handle_timestamp_minus(lhs, rhs)
         }
         // if two intervals are being added/subtracted, check their interval 
units and return the corresponding interval data type
-        (lhs, rhs, _) if is_interval(lhs) && is_interval(rhs) => 
handle_interval_addition(lhs, rhs),
+        (lhs, rhs, _) if is_interval(lhs) && is_interval(rhs) => {
+            handle_interval_addition(lhs, rhs)
+        }
         // if two date/timestamp are being added/subtracted, return an error 
indicating that the operation is not supported
-        (lhs, rhs, _) if (is_date(lhs) || is_timestamp(lhs)) && (is_date(rhs) 
|| is_timestamp(rhs)) => {
-            Err(DataFusionError::Plan(format!(
-                "{lhs_type:?} {rhs_type:?} is an unsupported operation. 
addition/subtraction on dates/timestamps only supported with interval types"
-            )))
+        (lhs, rhs, Operator::Minus)
+            if (is_date(lhs) || is_timestamp(lhs))
+                && (is_date(rhs) || is_timestamp(rhs)) =>
+        {
+            // TODO: support Minus

Review Comment:
   Yes, these code exist problem, I will fix it in other PR.
   In fact, we should allow datetime - datetime



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