Skip to content

Core: SchemaParser rejects integral JSON numbers for floating-point defaults #18119

Description

@laserninja

Apache Iceberg version

main (development), commit c4784768b

Query engine

Other: Java API

Please describe the bug

A schema with a double default expressed as JSON 1 fails to parse, while the equivalent 1.0 succeeds.

SchemaParser.fromJson("{\"type\":\"struct\",\"schema-id\":0,\"fields\":["
    + "{\"id\":1,\"name\":\"score\",\"required\":false,"
    + "\"type\":\"double\",\"initial-default\":1}]}");

Actual: IllegalArgumentException: Cannot parse default as a double value: 1.
Expected: a double default of 1.0. Appendix D specifies a JSON number for float/double values, and 1 is a valid numeric representation.

SingleValueParser requires Jackson's isFloatingPointNumber() for float/double, excluding integral numeric nodes. JSON producers may emit these values without a decimal point.

Proposed fix: accept numeric nodes for float/double while retaining rejection of strings and booleans. Cover both types and initial/write defaults through the schema parser.

Willingness to contribute

  • I can contribute a fix for this bug independently

This report and its reproduction were prepared with AI assistance and verified locally.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions