Skip to content

fix: write decimal types in the spec's canonical "decimal(P, S)" form - #1146

Open
WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix/decimal-json-spacing
Open

WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix/decimal-json-spacing

Conversation

@WZhuo

@WZhuo WZhuo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1142.

Since apache/iceberg#18145, Appendix C of the spec serializes a decimal type as "decimal(<P>, <S>)", with "decimal(9, 2)" as its only example. ToJson wrote "decimal(9,2)". DecimalType::ToString and Java already write the spaced form.

TypeFromJson accepts both spellings, so metadata written before this change still reads.

Tests:

  • The decimal case in TypeJsonTest.SingleTypeRoundTrip now expects "decimal(10, 2)".
  • TypeJsonTest.FromJsonWithSpaces now also checks that "decimal( 10, 2 )" and "decimal(10,2)" both parse and are written back as "decimal(10, 2)".

The iceberg-verification cases types/primitive/decimal-9-2 and types/primitive/decimal-9-2-spaced (#1144) pass with this change.

@WZhuo
WZhuo marked this pull request as draft November 19, 2026 04:06
@WZhuo
WZhuo force-pushed the fix/decimal-json-spacing branch 2 times, most recently from cea40e6 to 4a9e2fe Compare November 20, 2026 04:07
Appendix C of the spec serializes a decimal type as "decimal(<P>, <S>)",
with "decimal(9, 2)" as its example, since apache/iceberg#18145. ToJson
wrote "decimal(9,2)". DecimalType::ToString and Java already write the
spaced form.

TypeFromJson accepts both spellings, so existing metadata still reads.

Closes apache#1142.
@WZhuo
WZhuo force-pushed the fix/decimal-json-spacing branch from 4a9e2fe to e4765dd Compare November 24, 2026 07:19
@WZhuo
WZhuo marked this pull request as ready for review November 24, 2026 07:20

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.

ToJson writes decimal types without the space the spec requires

1 participant