fix: do not panic when displaying a Date64 scalar of i64::MIN - #24893
Draft
edubraqd wants to merge 1 commit into
Draft
fix: do not panic when displaying a Date64 scalar of i64::MIN#24893edubraqd wants to merge 1 commit into
Date64 scalar of i64::MIN#24893edubraqd wants to merge 1 commit into
Conversation
`ScalarValue::Date64` formatting unwrapped `chrono::Duration::try_milliseconds`, which returns `None` for `i64::MIN` because that value is below the range `chrono::Duration` can represent. Any plan that prints such a literal, for example `EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64')`, panicked with "called `Option::unwrap()` on a `None` value". Chain the two fallible steps instead so an unrepresentable date formats as an empty string, the same way an out-of-range epoch offset already does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
edubraqd
marked this pull request as draft
September 4, 2026 13:18
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.
Which issue does this PR close?
Date64scalar ofi64::MINpanics #24892.Rationale for this change
ScalarValue::Date64formatting unwrapschrono::Duration::try_milliseconds, which isNonefori64::MIN. Printing such a literal, for exampleEXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64'), panics instead of producing a plan.What changes are included in this PR?
Chain
try_millisecondsandchecked_add_signedwithand_then, so a value thatchrono::Durationcannot hold is treated the same as a date that is out of range: it formats as an empty string, which is what the existing out-of-range handling (added for apache/arrow-rs#7728) already does.Are these changes tested?
Yes.
test_display_date64_large_valuesnow also coversi64::MIN(which used to panic) andi64::MAX.Are there any user-facing changes?
No panic when a
Date64literal ofi64::MINis displayed.