Skip to content

Row-group stats decode aborts the read on minimum-length BYTE_ARRAY decimal bounds #3280

Closed

Description

@anoopj

Apache Iceberg Rust version

main@119fad92c891c95a7819d87e4195407b3f7c0578

Describe the bug

Surfaced during #3247 (companion to #3264).

get_parquet_stat_min_as_datum / get_parquet_stat_max_as_datum in crates/iceberg/src/arrow/schema.rs decode BYTE_ARRAY decimal statistics with a strict 16-byte conversion:

PrimitiveLiteral::Int128(i128::from_be_bytes(bytes.try_into()?)),

Parquet stores BYTE_ARRAY decimals as variable-length, minimal-byte-count, big-endian two's-complement values, so a bound shorter than 16 bytes (the common case) makes try_into() error and the ? propagates it, aborting the entire row-group read before scan planning completes.

The FIXED_LEN_BYTE_ARRAY decimal arm immediately below already handles this correctly with the variable-length helper i128_from_be_bytes(bytes) and a graceful DataInvalid error. The BYTE_ARRAY arm should use the same path (both min and max sites).

This is the row-group counterpart to the page-index behavior in #3247: that PR degraded the same malformed-bound class to "skip pruning" at the page-index layer, but the row-group stats layer still hard-errors, so "a malformed bound aborts the read" is not closed end-to-end.

From format/spec.md:1549 (the Parquet physical-type mapping):

decimal(P,S) → P <= 9: int32, P <= 18: int64, fixed otherwise
Fixed must use the minimum number of bytes that can store P.

So the spec mandates exactly three encodings: int32, int64, or fixed (FIXED_LEN_BYTE_ARRAY, chosen by precision. binary/BYTE_ARRAY is not a conformant decimal encoding in Iceberg. So this is purely a defensive fix and lower priority.

To Reproduce

No response

Expected behavior

Fix direction: replace i128::from_be_bytes(bytes.try_into()?) with i128_from_be_bytes(bytes) (as the FIXED_LEN arm does) at both the min and max decimal-BYTE_ARRAY sites, and add regression coverage for a sub-16-byte BYTE_ARRAY decimal bound.

Willingness to contribute

I can contribute a fix for this bug independently

Activity

  1. added
    bug
    on Sep 25, 2026
  2. added a commit that references this issue on Oct 12, 2026
    6933390
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions