Skip to content

fix: add space in decimal type serialization for cross-engine compat#2538

Open
SreeramGarlapati wants to merge 1 commit into
apache:mainfrom
SreeramGarlapati:fix/decimal-type-serialization-spacing
Open

fix: add space in decimal type serialization for cross-engine compat#2538
SreeramGarlapati wants to merge 1 commit into
apache:mainfrom
SreeramGarlapati:fix/decimal-type-serialization-spacing

Conversation

@SreeramGarlapati
Copy link
Copy Markdown
Contributor

Summary

iceberg-rust serializes the decimal type as decimal(P,S) (no space), while the Iceberg spec, Java, and Python all use decimal(P, S) (space after comma). This mismatch can cause issues when metadata written by iceberg-rust is read by strict parsers in other implementations.

What changed

  • serialize_decimal: decimal({precision},{scale})decimal({precision}, {scale})
  • Display for PrimitiveType: same fix for the decimal arm
  • Updated the one test fixture that asserted the old format

Why this is safe

The deserializer already uses .trim() on both precision and scale components, so it accepts both decimal(9,2) and decimal(9, 2). Existing metadata files with the old format continue to be readable.

Closes #2534

Test plan

  • All 1300+ iceberg crate tests pass
  • Workspace compiles cleanly
  • Backwards compat: deserializer handles both formats via trim()

…pliance

The Iceberg spec, Java, and Python all serialize the decimal type as
`decimal(P, S)` (with a space after the comma). iceberg-rust was writing
`decimal(P,S)` which could cause metadata written by Rust to be rejected
or misinterpreted by strict parsers in other implementations.

The deserializer already handles both formats via trim(), so this change
is backwards-compatible for reading.

Closes apache#2534

Co-authored-by: rawataaryan9 <rawataaryan9@users.noreply.github.com>
@SreeramGarlapati SreeramGarlapati force-pushed the fix/decimal-type-serialization-spacing branch from 945b288 to 3499e4b Compare May 30, 2026 04:31
Copy link
Copy Markdown
Collaborator

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @SreeramGarlapati!

Copy link
Copy Markdown
Contributor

@xanderbailey xanderbailey left a comment

Choose a reason for hiding this comment

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

Interestingly the spec makes it seem like this is legitimate both with and without the space? It would appear that if other consumers are failing here, they're not compliant?

Interested to know what other people in the community think the right approach here is? It's true that this fix will align with other clients but I also feel like perhaps we either need to clarify the spec or improve the other clients to be compliant?

@mbutrovich mbutrovich self-requested a review June 1, 2026 11:54
Copy link
Copy Markdown
Collaborator

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

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

Changing my approval after the better investigation by @xanderbailey, thanks for double-checking!

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.

decimal type serialized as decimal(P,S) — diverges from spec/java/python

3 participants