Repository navigation
fix(arrow-json): reject out-of-range float timestamps instead of saturating - #12007
Merged
Merged
Conversation
…rating A JSON number that does not parse as i64 fell back to f64 and was cast with `as i64`, so 1e30 silently became i64::MAX (and -1e30 i64::MIN). Use NumCast like the primitive decoder so the value is reported as a parse error, or read as null with ignore_type_conflicts.
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?
Rationale for this change
When a JSON number for a
Timestampcolumn doesn't parse asi64, the reader falls back tof64and casts withas i64, which saturates.{"time": 1e30}read asTimestamp(Second)silently becomesi64::MAX, and displaying the batch then fails withCast error: Failed to convert 9223372036854775807 to timestamp.The primitive decoder (Int64, Date32, Time, Duration) uses
NumCast::fromfor the same fallback. So an out-of-range float is a "failed to parse" error there, or null withwith_ignore_type_conflicts(true). Timestamps did neither.What changes are included in this PR?
The timestamp decoder uses the same
NumCast::fromfallback asprimitive_array.rs. In-range values, including fractional ones that truncate, are unchanged.Are these changes tested?
Yes.
test_timestamp_float_out_of_rangecovers ±1e30, 2^63, 1e999 (error, or null when ignoring type conflicts) and -2^63 (stilli64::MIN).Are there any significant user-facing changes?
Out-of-range float timestamps now produce an error (or null with
with_ignore_type_conflicts) instead of a saturatedi64::MAX/i64::MIN, matching the other numeric types.AI disclosure: the bug was found and the patch and test drafted with AI assistance (Claude); I reviewed every line, verified the failing test before/after the fix, and ran fmt/clippy/tests for the crate.