-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ::interval
casting / INTERVAL
SQL datatype
#5651
Comments
::interval
casting::interval
casting / Interval SQL datatype
::interval
casting / Interval SQL datatype::interval
casting / INTERVAL
SQL datatype
@waitingkuo I would be curious to know what you think about this proposal |
To avoid data compatibility problem we must use IntervalMonthDayNano to store. But I think maybe we could provide some optional output formats like postgresql? Because directly displaying IntervalMonthDayNano is somewhat tediously long like |
I agree this would be a good idea. Ideally we could add some options to the arrow display module to support different output formats. I plan to file some tickets about interval support shortly, and I will include more display as well |
hi @alamb this is great, I'd like to know when the source doesn't feed into the interval , e.g. select arrow_cast('1 second', 'Interval(YearMonth)'); do we just simply return a or when there're some ambiguities select arrow_cast('1 month', 'Interval(DayTime)'); do we return |
I think the best way to think of So in your examples select arrow_cast('1 second', 'Interval(YearMonth)'); That would invoke select arrow_cast('1 month', 'Interval(DayTime)'); Basically this should be whatever the arrow casting kernel does (probably throw an ambiguity error, but I am not sure) |
After upgrade to arrow 36: select arrow_cast('1 second', 'Interval(YearMonth)');DataFusion CLI v21.0.0
❯ select arrow_cast('1 second', 'Interval(YearMonth)');
Arrow error: Cast error: Cannot cast 1 second to IntervalYearMonth. Only year and month fields are allowed.
❯ select arrow_cast('1 month', 'Interval(DayTime)');
+--------------------------------------------------+
| Utf8("1 month") |
+--------------------------------------------------+
| 0 years 0 mons 30 days 0 hours 0 mins 0.000 secs |
+--------------------------------------------------+ Here is a small PR that adds basic support for the SQL interval type: #5792 |
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_bin
doesn't work withmonths
oryears
#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
The text was updated successfully, but these errors were encountered: