You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "berkaysynnada (via GitHub)" <gi...@apache.org> on 2023/04/11 06:57:43 UTC

[GitHub] [arrow-datafusion] berkaysynnada commented on a diff in pull request #5932: just match for BinaryExpr Date/Time +/- Interval

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org