ax1s-x1zz commented on issue #6390:
URL: https://github.com/apache/arrow-rs/issues/6390#issuecomment-5559285843

   I'd like to pick this up. Here's what I found and the scope I propose.
   
   ## Root cause
   
   `"5 day hour"` is split by `split_interval_components` into `[("5", 
Some("day")), ("", Some("hour"))]`. The empty amount string `""` then fails 
`IntervalAmount::from_str`, producing `Invalid input syntax for type interval` 
(see the DataFusion slt case `interval '5 day' hour`, which becomes `"5 day 
HOUR"`).
   
   ## Proposed change
   
   In `parse_interval_components` (arrow-cast/src/parse.rs), treat a unit with 
no amount as an amount of 0 — i.e. `"5 day hour"` parses like `"5 day 0 hour"`:
   
   - empty amount string → `IntervalAmount { integer: 0, frac: 0 }`
   - everything else unchanged: unknown units and repeated units still error
   
   ## Scope
   
   This only relaxes the *bare unit* case (amount omitted). Unit-before-number 
ordering (e.g. `"hour 5"`) is a separate concern and is left alone.
   
   Regression tests will cover `Interval::parse("5 day hour", ...)` == 5 days 
and the public `parse_interval_month_day_nano_config("5 day hour", ...)` path.
   
   Does this match what you had in mind, or should the bare-unit-as-zero rule 
be restricted to trailing units only?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to