Skip to content

fix(iceberg): Implement JSON serde for Fixed/Binary literals#2436

Open
YuangGao wants to merge 1 commit into
apache:mainfrom
YuangGao:fix/literal-fixed-binary-json
Open

fix(iceberg): Implement JSON serde for Fixed/Binary literals#2436
YuangGao wants to merge 1 commit into
apache:mainfrom
YuangGao:fix/literal-fixed-binary-json

Conversation

@YuangGao
Copy link
Copy Markdown

Which issue does this PR close?

What changes are included in this PR?

Fixes two bugs in Literal JSON serialization for Fixed/Binary:

  • try_from_json: replace todo!() with hex parsing; Fixed(n) validates length, invalid input returns DataInvalid instead of panicking.
  • try_into_json: change "{x:x}" to "{x:02x}" so bytes < 0x10 keep their leading zero (e.g. [0x00, 0xff, 0x05] now encodes to "00ff05", not "0ff5").

The two bugs masked each other — no existing test covered the Fixed/Binary JSON path. No new dependencies (uses u8::from_str_radix).

Are these changes tested?

Yes, four new unit tests in crates/iceberg/src/spec/values/tests.rs:

  • test_json_serde_binaryBinary round-trip with "00ff05" (regression for the zero-padding bug).
  • test_json_serde_fixedFixed(4) round-trip.
  • test_try_from_json_fixed_length_mismatchFixed(5) rejects 4-byte hex input.
  • test_try_from_json_binary_invalid_hex — non-hex input returns Err.

@YuangGao YuangGao marked this pull request as ready for review May 12, 2026 05:23
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.

bug(spec): JSON literal serialization for Fixed/Binary is broken in both directions

1 participant