DuanRuixiao opened a new pull request, #17502: URL: https://github.com/apache/iceberg/pull/17502
## Problem `FixedByteBufferWriter.write()` was calling `encoder.writeBytes()`, which prepends a zigzag-encoded length prefix before the payload. For Avro `fixed[N]` fields this is wrong — the reader expects exactly N bytes with no prefix. The stray length byte spills into the next field in the record and corrupts it. For example, writing a `FIXED(3)` partition value `[AB CD EF]` produced `[06 AB CD EF]` on disk (where `06` is `zigzag(3)`). The reader then consumed `[06 AB CD]` as the partition value, and the leftover `[EF]` corrupted the subsequent `record_count` field, decoding it as `-568` instead of the actual row count. The symmetric read path in `InternalReader` had the same issue: `case FIXED:` fell through to `case BYTES:` and used `byteBuffers()` (`decoder.readBytes()`), which reads a length-prefixed byte sequence instead of a fixed-size one. ## Fix - **`ValueWriters`**: `FixedByteBufferWriter.write()` now extracts the bytes into a `byte[]` and calls `encoder.writeFixed()` (exact N bytes, no prefix), matching the existing `FixedWriter` for `byte[]`. - **`ValueReaders`**: Add `FixedByteBufferReader` that calls `decoder.readFixed(bytes, 0, length)` / `decoder.skipFixed(length)`. Expose it via `ValueReaders.fixedBuffers(int length)`. - **`InternalReader`**: `case FIXED:` now returns `ValueReaders.fixedBuffers(primitive.getFixedSize())` instead of falling through to the bytes reader. ## Tests `TestFixedByteBufferWriter` adds two regression tests: - **`testFixedWriterProducesExactBytes`** — directly verifies the encoder emits exactly N bytes with no length prefix. - **`testManifestRoundTripWithFixedPartition`** — writes and reads back a manifest with a `FIXED(3)` identity-partition column; asserts both the partition value and `record_count` survive the round-trip uncorrupted. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
