alamb commented on code in PR #3110:
URL: https://github.com/apache/arrow-datafusion/pull/3110#discussion_r944323903


##########
datafusion/physical-expr/src/expressions/datetime.rs:
##########
@@ -45,19 +45,21 @@ impl DateIntervalExpr {
         input_schema: &Schema,
     ) -> Result<Self> {
         match lhs.data_type(input_schema)? {
-            DataType::Date32 | DataType::Date64 => match 
rhs.data_type(input_schema)? {
-                DataType::Interval(_) => match &op {
-                    Operator::Plus | Operator::Minus => Ok(Self { lhs, op, rhs 
}),
-                    _ => Err(DataFusionError::Execution(format!(
-                        "Invalid operator '{}' for DateIntervalExpr",
-                        op
+            DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _) => 
{
+                match rhs.data_type(input_schema)? {
+                    DataType::Interval(_) => match &op {
+                        Operator::Plus | Operator::Minus => Ok(Self { lhs, op, 
rhs }),
+                        _ => Err(DataFusionError::Execution(format!(
+                            "Invalid operator '{}' for DateIntervalExpr",
+                            op
+                        ))),
+                    },
+                    other => Err(DataFusionError::Execution(format!(

Review Comment:
   I know you didn't change this, but this error message would be more accurate 
as 
   
   ```rust
   DataFusionError::NotYetImplemented(format!("Operation '{}' not support for 
type {}", op, other)))
   ```



##########
datafusion/physical-expr/src/expressions/datetime.rs:
##########
@@ -45,19 +45,21 @@ impl DateIntervalExpr {
         input_schema: &Schema,
     ) -> Result<Self> {
         match lhs.data_type(input_schema)? {
-            DataType::Date32 | DataType::Date64 => match 
rhs.data_type(input_schema)? {
-                DataType::Interval(_) => match &op {
-                    Operator::Plus | Operator::Minus => Ok(Self { lhs, op, rhs 
}),
-                    _ => Err(DataFusionError::Execution(format!(
-                        "Invalid operator '{}' for DateIntervalExpr",
-                        op
+            DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _) => 
{
+                match rhs.data_type(input_schema)? {
+                    DataType::Interval(_) => match &op {

Review Comment:
   Since `DateIntervalExpr` now handles Timestamps in addition to `Date`s 
perhaps we should rename it to `DateTimeIntervalExpr` -- we can do that as a 
follow on PR



##########
datafusion/physical-expr/src/expressions/datetime.rs:
##########
@@ -130,27 +112,62 @@ impl PhysicalExpr for DateIntervalExpr {
             }
         };
 
-        // Do math
-        let posterior = match scalar {
-            ScalarValue::IntervalDayTime(Some(i)) => add_day_time(prior, *i, 
sign),
-            ScalarValue::IntervalYearMonth(Some(i)) => shift_months(prior, *i 
* sign),
-            ScalarValue::IntervalMonthDayNano(Some(i)) => add_m_d_nano(prior, 
*i, sign),
-            other => Err(DataFusionError::Execution(format!(
-                "DateIntervalExpr does not support non-interval type {:?}",
-                other
-            )))?,
+        // Unwrap days since epoch
+        let operand = match dates {
+            ColumnarValue::Scalar(scalar) => scalar,
+            _ => Err(DataFusionError::Execution(
+                "Columnar execution is not yet supported for DateIntervalExpr"

Review Comment:
   Yeah -- @avantgardnerio  did some work to start supporting this in 
https://github.com/apache/arrow-rs/issues/527
   
   



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