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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -276,18 +280,16 @@ fn handle_timestamp_minus(lhs: &DataType, rhs: &DataType) 
-> Result<Option<DataT
         | (
             DataType::Timestamp(TimeUnit::Millisecond, _),
             DataType::Timestamp(TimeUnit::Millisecond, _),
-        ) => Ok(Some(DataType::Interval(IntervalUnit::DayTime))),
+        ) => Some(DataType::Interval(IntervalUnit::DayTime)),
         (
             DataType::Timestamp(TimeUnit::Microsecond, _),
             DataType::Timestamp(TimeUnit::Microsecond, _),
         )
         | (
             DataType::Timestamp(TimeUnit::Nanosecond, _),
             DataType::Timestamp(TimeUnit::Nanosecond, _),
-        ) => Ok(Some(DataType::Interval(IntervalUnit::MonthDayNano))),
-        (_, _) => Err(DataFusionError::Plan(
-            "The timestamps have different types".to_string(),
-        )),
+        ) => Some(DataType::Interval(IntervalUnit::MonthDayNano)),
+        (_, _) => None,

Review Comment:
   Yes, the subtraction of different timestamp types needs special handling. I 
think if the operation is done with second or millisecond-precision timestamps, 
`IntervalDayTime` type could be coerced, and for the other timestamp types 
`IntervalMonthDayNano` seems to be the only option.



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