You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "swanandx (via GitHub)" <gi...@apache.org> on 2026/05/11 11:50:31 UTC

[I] Date32 doesn't parse date with large year [arrow-rs]

swanandx opened a new issue, #9960:
URL: https://github.com/apache/arrow-rs/issues/9960

   **Describe the bug**
   
   Date32Type::parse does not parse date strings whose year is outside `chrono::NaiveDate`'s range (Jan 1, 262145 BCE to Dec 31, 262143 CE )
   
   Ideally Date32 should be able to represent much larger range (i32 days from epoch; years ≈ ±5,881,580).
   
   the extended-year branch in parse_date calls `chrono::NaiveDate::from_ymd_opt`, limiting the supported range.
   
   https://github.com/apache/arrow-rs/blob/7abb2255f2de045ca8dcd12e1e46377e11de5b9f/arrow-cast/src/parse.rs#L612
   
   In the end, all we need is i32, so we can avoid `NaiveDate` detour
   
   **To Reproduce**
   
   Try to parse date outside NaiveDate supported range
   
   ```rs
   use arrow_array::types::Date32Type;
   use arrow_cast::parse::Parser;
   
   fn main() {
       // Works: year is within chrono::NaiveDate's supported range.
       assert_eq!(Date32Type::parse("+29349-01-26"), Some(10_000_000));
   
       // Fails today: returns None. This should be accepted because the resulting
       // day offset is still representable by Date32.
       assert_eq!(Date32Type::parse("+2739877-01-03"), Some(1_000_000_000));
   }
   ```
   
   **Expected behavior**
   
   All valid Date32 should be parsed successfully 
   
   **Additional context**
   
   arrow-array = "58.2.0"
   arrow-cast = "58.2.0"
   
   
   Easy approach would be:
   The Gregorian calendar repeats exactly every 400 years (146,097 days), so we calculate current _era_ ( era = y.div_euclid(400) )  and _year in current era_ ( yoe =  y.rem_euclid(400) ). Year in era would be 0..=399, so always within chrono's supported range, which we can use to calculate days / validation
   
   ```rs
   let nd = NaiveDate::from_ymd_opt(yoe, month, day)?;
   let in_era = (nd.num_days_from_ce() - EPOCH_DAYS_FROM_CE) as i64;
   days =  i32::try_from(era * 146_097 + in_era).ok();
   ```
   
   Other can be to update `parse_date` signature itself? or something else?


-- 
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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Date32 doesn't parse date with large year [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed issue #9960: Date32 doesn't parse date with large year
URL: https://github.com/apache/arrow-rs/issues/9960


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Date32 doesn't parse date with large year [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #9960:
URL: https://github.com/apache/arrow-rs/issues/9960#issuecomment-4616723971

   `label_issue.py` automatically added labels {'arrow'} from #9961


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Date32 doesn't parse date with large year [arrow-rs]

Posted by "swanandx (via GitHub)" <gi...@apache.org>.
swanandx commented on issue #9960:
URL: https://github.com/apache/arrow-rs/issues/9960#issuecomment-4420423521

   take


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org