-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request