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/02/27 10:11:54 UTC
[GitHub] [arrow-datafusion] berkaysynnada opened a new issue, #5411: Timestamp Subtraction
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: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb closed issue #5411: Timestamp Subtraction
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #5411: Timestamp Subtraction
URL: https://github.com/apache/arrow-datafusion/issues/5411
--
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
[GitHub] [arrow-datafusion] metesynnada commented on issue #5411: Timestamp Subtraction
Posted by "metesynnada (via GitHub)" <gi...@apache.org>.
metesynnada commented on issue #5411:
URL: https://github.com/apache/arrow-datafusion/issues/5411#issuecomment-1446054524
This is also important for supporting queries for interval arithmetics, i.e range calculations.
--
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