Skip to content

Validate FIXED_LEN_BYTE_ARRAY type_length for DECIMAL and INTERVAL in Parquet → Arrow schema conversion #9984

Closed

Description

@CynicDog

Is your feature request related to a problem or challenge?

parquet/src/arrow/schema/primitive.rs::from_fixed_len_byte_array carries a long-standing TODO from PR #1682:

// TODO: This should check the type length for the decimal and interval types

PrimitiveTypeBuilder::build() properly enforces type_length constraints during schema construction (schema/types.rs:477 for INTERVAL, :565-580 for DECIMAL precision-vs-length), but schemas decoded directly from Thrift bypass these checks entirely. This allows the reader-side conversion to silently produce an Arrow type that doesn't match the actual on-disk layout when:

  • DECIMAL has a type_length outside 1..=32 — it silently routes through Decimal128 / Decimal256 using invalid parameters.
  • INTERVAL has a type_length != 12 — it silently returns Interval(DayTime) regardless.

The same function already handles FLOAT16 correctly by returning an error when type_length != 2.

Describe the solution you'd like

In from_fixed_len_byte_array, validate type_length mirroring the existing FLOAT16 pattern:

  • DECIMAL (logical and converted): require 1 <= type_length <= 32 (Decimal128 fits within 16 bytes; Decimal256 up to 32).
  • INTERVAL converted type: require type_length == 12 per the Parquet format spec.

Return ParquetError::General with a clear message stating the expected range/value and the actual value.

Describe alternatives you've considered

  • Replicating the builder's fuller precision-vs-length check on the reader side. Rejected: that duplicates PrimitiveTypeBuilder::check_decimal_precision_scale and unnecessarily expands the scope. Length-range validation alone is enough to catch the cases that produce a mismatched Arrow type.
  • Doing nothing and letting downstream Arrow construction fail later. Rejected: errors would surface far from the root cause, making troubleshooting much more difficult.

Additional context

  • Source: parquet/src/arrow/schema/primitive.rs:316
  • TODO introduced in PR Fix Parquet Reader's Arrow Schema Inference #1682 (Fix Parquet Arrow Schema Inference)
  • Builder-side checks already present at schema/types.rs:477 (INTERVAL) and :565-580 (DECIMAL precision-vs-length).

Activity

  1. CynicDog commented on May 16, 2026

    @CynicDog
    ContributorAuthor

    take

  2. added a commit that references this issue on May 28, 2026
    1377761
  3. added a commit that references this issue on Jun 2, 2026
    b07676a
  4. added
    parquet
    on Jun 3, 2026
  5. alamb commented on Jun 3, 2026

    @alamb
    Contributor

    label_issue.py automatically added labels {'parquet'} from #9985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

parquet

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions