ax1s-x1zz commented on code in PR #11006:
URL: https://github.com/apache/arrow-rs/pull/11006#discussion_r3945627583


##########
arrow-cast/src/parse.rs:
##########
@@ -1653,7 +1653,19 @@ fn parse_interval_components(
     // parse amounts and units
     let Ok(pairs): Result<Vec<(IntervalAmount, IntervalUnit)>, ArrowError> = 
raw_pairs
         .iter()
-        .map(|(a, u)| Ok((a.parse()?, IntervalUnit::from_str_or_config(*u, 
config)?)))
+        .map(|(a, u)| {
+            // A unit with no preceding amount (e.g. the "hour" in "5 day 
hour")
+            // is treated as an amount of zero, matching PostgreSQL.
+            let amount = if a.is_empty() {

Review Comment:
   Good catch. I've tightened the change so an empty amount is only treated as 
zero when a unit is actually present (`a.is_empty() && u.is_some()`), leaving 
`Interval::parse("")` invalid.
   
   Added a regression to `test_interval_bare_units` asserting `""` still 
errors, and verified that test fails if the `u.is_some()` guard is removed.
   
   This also means the change is now strictly scoped to #6390's 
unit-without-amount case: the zero only applies to strings that contain a bare 
unit.
   



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