Skip to content

fix: accept any JSON number for float and double in LiteralFromJson - #1212

Open
WZhuo wants to merge 2 commits into
apache:mainfrom
WZhuo:fix/literal-from-json-any-number
Open

WZhuo wants to merge 2 commits into
apache:mainfrom
WZhuo:fix/literal-from-json-any-number

Conversation

@WZhuo

@WZhuo WZhuo commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

The spec's JSON single-value serialization (Appendix D) defines float and double values as JSON numbers. LiteralFromJson only checked is_number_float(), so it rejected whole-number literals such as 0. This also affects schema initial-default/write-default and partition values, which are decoded through LiteralFromJson.

This change accepts any JSON number for float and double, and rejects values that overflow to infinity (for example 1e39 as a float). Serialization is unchanged.

The same change is in progress in Java: apache/iceberg#19279 (dev@ thread: https://lists.apache.org/thread/1dn6c2ytq0qpwgvv2tqr9wvyswdxhh2t). With this fix, the identity-float and identity-double cases of the partition-transforms verification surface (#1173) pass.

Testing

Added LiteralFromJsonTest.FloatAndDoubleValues (whole numbers, integers outside the int/long ranges, rounding, max float) and LiteralFromJsonTest.RejectsInvalidFloatAndDouble (overflow, quoted numbers, booleans).

WZhuo added 2 commits December 4, 2026 12:43
The spec defines float and double single values as JSON numbers, but
LiteralFromJson only accepted floating-point literals, so whole-number
literals such as 0 were rejected. Accept any JSON number, and reject
values that overflow to infinity.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants