berkaysynnada opened a new issue, #5411:
URL: https://github.com/apache/arrow-datafusion/issues/5411

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   The timestamp variants (`TimestampSecond`, `TimestampMillisecond` ...) in 
`ScalarValue` cannot be subtracted from the same timestamp variant. I think we 
can subtract the timestamp within each variant and get some interval data 
variants (`IntervalYearMonth`, `IntervalDayTime`).
   
   **Describe the solution you'd like**
   There is a function in scalar.rs:
   ```
   fn do_date_math<D>(prior: D, scalar: &ScalarValue, sign: i32) -> Result<D>
   where
       D: Datelike + Add<Duration, Output = D>,
   {
       Ok(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:?}"
           )))?,
       })
   }
   ```
   This function can be extended to handle the subtraction of timestamps and 
can return an interval variant.
   
   **Describe alternatives you've considered**
   Before entering `do_date_math` function, these cases can be handled with an 
alternative function in `impl_op` macro.
   
   **Additional context**
   -
   


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