-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In DataFusion we are trying to add complete date/time support . IN addition to Interval types some of this arithmetic will also likely result in Durations (e.g. timestamp - timestamp -- see #3964)
DataType::Duration(TimeUnit::Second)
DataType::Duration(TimeUnit::Millisecond)
DataType::Duration(TimeUnit::Microsecond)
DataType::Duration(TimeUnit::NanoSecond)
DataType::Interval(IntervalUnit::YearMonth)
DataType::Interval(IntervalUnit::DayTime)
DataType::Interval(IntervalUnit::MonthDayNano)
However, there is no easy way currently to convert between Durations and Intervals
Describe the solution you'd like
Add support for casting durations to intervals to the cast kernel : https://github.com/apache/arrow-rs/blob/master/arrow-cast/src/cast.rs#L18-L36
The following casts should be always supported as they are lossless (DataType::Interval(IntervalUnit::MonthDayNano) has nanosecond precision)
DataType::Duration(TimeUnit::Second)<-->DataType::Interval(IntervalUnit::MonthDayNano)DataType::Duration(TimeUnit::Millisecond)<-->DataType::Interval(IntervalUnit::MonthDayNano)DataType::Duration(TimeUnit::Microsecond)<-->DataType::Interval(IntervalUnit::MonthDayNano)DataType::Duration(TimeUnit::NanoSecond)<-->DataType::Interval(IntervalUnit::MonthDayNano)
I am not sure what other, if any, casts should be supported
Describe alternatives you've considered
Additional context