fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961
Open
swanandx wants to merge 1 commit into
Open
fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961swanandx wants to merge 1 commit into
swanandx wants to merge 1 commit into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Date32Type::parsepreviously usedchrono::NaiveDate, which caps at roughly +-262,143 years and rejected valid ISO 8601 extended-year inputs like+2739877-01-03As 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