-
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 support SQL syntax like INTERVAL 3 months that is then converted into Intervals (I think originally contributed by @ovr).
However we currently only support converting individual values (rather than arrays)
Describe the solution you'd like
I would like the arrow cast kernel https://docs.rs/arrow-cast/32.0.0/arrow_cast/cast/fn.cast.html to support casting to/from strings and intervals
DataType::Interval(_) <----> DataType::Utf8/DataType::LargeUtf8
There is some subtlety related to parsing intervals (like if a given interval type can fit a specific range and precision)
Describe alternatives you've considered
Additional context
The datafusion parse_interval logic is here: https://github.com/apache/arrow-datafusion/blob/1f7885bb48dd33ce7b9df995214393bbff080e08/datafusion/common/src/parsers.rs#L115-L266
I think it would be fairly straightforward to port (along with tests) to arrow-rs
I don't think arrow should have the logic that tries to auto-detect the type of the interval -- in DataFusion I think we could simply change the code to try parsing the string as different types of intervals and use the one that first succeeds.