SashaMIT opened a new pull request, #11306:
URL: https://github.com/apache/arrow-rs/pull/11306

   # Which issue does this PR close?
   
   No existing issue.
   
   # Rationale for this change
   
   `parse_interval_month_day_nano("0.01 months")` returned 0 months, 0 days, 
and 0 nanoseconds. A fractional month is 30 days, and 0.01 month is 0.3 days, 
which is 7 hours 12 minutes. Postgres returns `07:12:00`. `0.04 months` 
returned 1 day and dropped the remaining 4 hours 48 minutes. Postgres returns 
`1 day 04:48:00`.
   
   `0.5 months` stays 15 days. `0.1 months` stays 3 days. `-0.5 months` stays 
-15 days. Years still round to whole months and do not spill into days, which 
the comment already states.
   
   # What changes are included in this PR?
   
   The month path already converted the fraction to whole days with `frac * 3 / 
10^(INTERVAL_PRECISION - 1)`. The remainder of that division is now 
nanoseconds: `remainder * 108 / 125`, which is `remainder * 86_400e9 / 10^14`.
   
   # Are these changes tested?
   
   `cargo test -p arrow-cast --lib parse::` (35 passed).
   
   Red before the fix: `0.01 months` was `(0, 0, 0)`. Green after: 7 hours 12 
minutes, and `0.04 months` is 1 day 4 hours 48 minutes. `-0.01 months` is -7 
hours 12 minutes.
   
   `cargo clippy -p arrow-cast --lib -- -D warnings` passed.
   
   # Are there any user-facing changes?
   
   Yes. A fractional month that is not a whole number of days now keeps the 
leftover time. `0.01 months` was a zero interval and is now 7 hours 12 minutes. 
Values that were already a whole number of days are unchanged.
   
   Drafted with Grok 4.7. The code has not yet been reviewed by a human.
   


-- 
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