You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In DataFusion, we support SQL syntax like INTERVAL '3 months' that is then converted into Intervals (I think originally contributed by @ovr).
It only works for constant strings in INTERVAL ... not more generally
Describe the solution you'd like
I would like to be able to use the interval type from sql as normal:
select'1 day`::intervalselect cast('1 day' as interval);select arrow_cast('1 day', 'Interval(MonthDayNano)');
Here is what happens today
❯ select '1 day'::interval;
This feature is not implemented: Unsupported SQL type Interval
❯ select cast('1 day' as interval);
This feature is not implemented: Unsupported SQL type Interval
❯ select arrow_cast('1 day', 'Interval(MonthDayNano)');
Error during planning: Cannot automatically convert Utf8 to Interval(MonthDayNano)
❯ select arrow_cast('1 day', 'Interval(YearMonth)');
Error during planning: Cannot automatically convert Utf8 to Interval(YearMonth)
❯ select arrow_cast('1 day', 'Interval(DayTime)');
Error during planning: Cannot automatically convert Utf8 to Interval(DayTime)
Describe alternatives you've considered
One thing we need to figure out is what Arrow interval type will map to the sql interval type.
Intervals can be either YearMonth or DayTime or MonthDayNano
I think in order to support '1 day' and '1 minute' with the same type, we will need to use IntervalMonthDayNano:
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In DataFusion, we support SQL syntax like
INTERVAL '3 months'that is then converted into Intervals (I think originally contributed by @ovr).This has a few limitations:
date_bindoesn't work withmonthsoryears#5689INTERVAL ...not more generallyDescribe the solution you'd like
I would like to be able to use the interval type from sql as normal:
Here is what happens today
Describe alternatives you've considered
One thing we need to figure out is what Arrow interval type will map to the sql interval type.
Intervals can be either YearMonth or DayTime or MonthDayNano
I think in order to support '1 day' and '1 minute' with the same type, we will need to use IntervalMonthDayNano:
https://docs.rs/arrow/35.0.0/arrow/datatypes/struct.IntervalMonthDayNanoType.html
Additional context
I believe the casting support is added upstream in arrow-rs by @doki23 -- apache/arrow-rs#3762 in arrow 35.0.0.
However, that upgrade is blocked (see #5441) so we may have to wait for arrow-36.0.0 to implement this feature