Skip to content

fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961

Open
swanandx wants to merge 1 commit into
apache:mainfrom
swanandx:date32-fix
Open

fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961
swanandx wants to merge 1 commit into
apache:mainfrom
swanandx:date32-fix

Conversation

@swanandx
Copy link
Copy Markdown

Date32Type::parse previously used chrono::NaiveDate, which caps at roughly +-262,143 years and rejected valid ISO 8601 extended-year inputs like +2739877-01-03

As Gregorian repeats in 400-year era (146,097 days), we find the current era and then calculate & validate the date in current era. We recover the absolute day count by adding era * 146,097.

Which issue does this PR close?

Rationale for this change

Supporting full range of date's allows other dependents like delta-rs to parse data written/managed by other engines like Spark which support full Date32

changing parse_date() signature is also other option but would need changes with Date64 as well.

What changes are included in this PR?

calculating number of days without converting it full extended year to NaiveDate. And tests for it.

Are these changes tested?

added tests and relying on existing tests for verification

Are there any user-facing changes?

Maybe as we parse some data successfully which would have previously been None / error

… dates

`Date32Type::parse` previously used `chrono::NaiveDate`, which
caps at roughly +-262,143 years and rejected valid ISO 8601 extended-year
inputs like `+2739877-01-03`

As Gregorian repeats in 400-year era (146,097 days), we find the current era and then
calculate & validate the date in current era. We recover the absolute
day count by adding era * 146,097.

Signed-off-by: Swanand Mulay <73115739+swanandx@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date32 doesn't parse date with large year

1 participant