Thanks Zhuo,

+1 to relaxing the reader and stating "any JSON number" in the spec.

iceberg-go hits this today: encoding/json writes 0.0 as 0, including
initial-default in metadata.json. So a Go-created v3 table with a float
default of 0.0 would fail to load in Java.

Would be also nice to add whole-number float cases for schema defaults and
expression iterals to iceberg-verification.

Andrei

On Sun, Nov 29, 2026 at 10:22 PM Zhuo Wang <[email protected]> wrote:

>
> Hi all,
>
> What we found in iceberg-cpp
>
> iceberg-cpp is adopting the apache/iceberg-verification fixtures. Its
> verification_test runs the partition-transforms surface (
> https://github.com/apache/iceberg-cpp/pull/1173): for each case it
> decodes input.values, applies the bound transform, decodes decoded.values,
> and compares. That surface writes float and double values as plain JSON
> numbers:
>
>     { "id": "identity-float",
>       "input":   { "transform": "identity", "source_type": "float”,
> "values": [null, -1.5, 0, 1.5] },
>       "decoded": { "result_types": ["float”], "values": [null, -1.5, 0,
> 1.5] } }
>
> identity-double is the same with -1.25, 0, 1.25. Decoding these values
> with iceberg-cpp's LiteralFromJson fails on values[2]: "Cannot parse 0 as a
> float value". LiteralFromJson requires a JSON number written with a
> fractional part or exponent, so it accepts 0.0 and rejects 0.
>
> Appendix D of the spec defines the JSON single-value serialization of
> float and double as a "JSON number", with 1.0 as the example. int and long
> are a "JSON int" and a "JSON long", so the spec does not seem to require a
> fractional part for floating-point values.
>
> Java has the same check: SingleValueParser.fromJson requires
> isFloatingPointNumber() for FLOAT and DOUBLE. I built iceberg-api and
> iceberg-core from main (2e12b22ae) and confirmed that a Java runner
> decoding the same fixtures would hit the same rejection. Each of these
> entry points rejects 0 and accepts 0.0:
>
> - SingleValueParser.fromJson, for both float and double
> - SchemaParser.fromJson, for initial-default
> - ExpressionParser.fromJson(json, schema)
>
> Every rejection is an IllegalArgumentException with the message "Cannot
> parse default as a float value: 0" (or double).
>
> The check is in SingleValueParser, so every caller that can see a float or
> double value is affected:
>
> - SchemaParser: initial-default and write-default (v3)
> - ContentFileParser: partition values of content files in REST scan
> planning, for example an identity partition on a float column
> - ExpressionParser: literals bound to a schema, for example REST scan
> planning filters
> - DataTaskParser: metadata table rows
>
> A writer does not have to be buggy to produce 0 or 1 here. Go's
> encoding/json and JavaScript's JSON.stringify both serialize the
> floating-point values 0.0 and 1.0 as 0 and 1. A REST server or a non-JVM
> writer built on either of them produces JSON that follows the spec, but
> Java cannot read it.
>
> Proposal
>
> Accept any JSON number for FLOAT and DOUBLE in SingleValueParser.fromJson,
> so isNumber() instead of isFloatingPointNumber(). The writer stays
> unchanged and keeps emitting 1.0, so existing readers are not affected. A
> large whole number is converted with the usual floating-point rounding,
> which is the same thing that already happens to a JSON value such as
> 1.0000000001. iceberg-cpp would make the same change in LiteralFromJson to
> stay consistent with Java, and the identity-float and identity-double test
> cases would then pass.
>
> Questions:
>
> 1. Do we agree that "JSON number" in Appendix D includes whole numbers
> written without a fractional part?
> 2. If yes, is relaxing the reader in Java (and then in iceberg-cpp) the
> right fix? Or would people rather clarify the spec to require a fractional
> part, and treat writers that omit it as non-conforming?
> 3. Either way, should the spec state the answer explicitly, for example
> "any JSON number" in the float and double rows?
>
> Thanks,
> Zhuo Wang
>
>

Reply via email to