Skip to content

fix(arrow-json): reject out-of-range float timestamps instead of saturating - #12007

Merged
Jefffrey merged 1 commit into
apache:mainfrom
hsdfat:json-timestamp-float-overflow
Nov 4, 2026
Merged

Jefffrey merged 1 commit into
apache:mainfrom
hsdfat:json-timestamp-float-overflow

Conversation

@hsdfat

@hsdfat hsdfat commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • None; small bug fix.

Rationale for this change

When a JSON number for a Timestamp column doesn't parse as i64, the reader falls back to f64 and casts with as i64, which saturates. {"time": 1e30} read as Timestamp(Second) silently becomes i64::MAX, and displaying the batch then fails with Cast error: Failed to convert 9223372036854775807 to timestamp.

The primitive decoder (Int64, Date32, Time, Duration) uses NumCast::from for the same fallback. So an out-of-range float is a "failed to parse" error there, or null with with_ignore_type_conflicts(true). Timestamps did neither.

What changes are included in this PR?

The timestamp decoder uses the same NumCast::from fallback as primitive_array.rs. In-range values, including fractional ones that truncate, are unchanged.

Are these changes tested?

Yes. test_timestamp_float_out_of_range covers ±1e30, 2^63, 1e999 (error, or null when ignoring type conflicts) and -2^63 (still i64::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 saturated i64::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.

…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.
@github-actions github-actions Bot added the arrow-json arrow-json crate label Oct 30, 2026
@Jefffrey Jefffrey added the bug Squash those bugs label Nov 4, 2026

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this @hsdfat

@Jefffrey
Jefffrey added this pull request to the merge queue Nov 4, 2026
Merged via the queue into apache:main with commit fdf8859 Nov 4, 2026
21 checks passed
@hsdfat
hsdfat deleted the json-timestamp-float-overflow branch November 6, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-json arrow-json crate bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants