CynicDog opened a new pull request, #9985:
URL: https://github.com/apache/arrow-rs/pull/9985

   # Which issue does this PR close?
   
   - Closes #9984.
   
   # Rationale for this change
   
   `from_fixed_len_byte_array` in `parquet/src/arrow/schema/primitive.rs` does 
not validate `type_length`. `PrimitiveTypeBuilder::build()` enforces these 
constraints at construction (`schema/types.rs:477` for INTERVAL, `:565-580` for 
DECIMAL), but schemas decoded directly from Thrift bypass that path. As a 
result:
   
   - `DECIMAL` with `type_length` outside `1..=32` silently routed through 
`Decimal128` / `Decimal256` with bogus inputs.
   - `INTERVAL` with `type_length != 12` silently returned `Interval(DayTime)` 
regardless.
   
   The same function already rejects `FLOAT16` when `type_length != 2`. This PR 
mirrors that pattern for DECIMAL and INTERVAL, closing the TODO introduced in 
#1682.
   
   # What changes are included in this PR?
   
   - `check_decimal_length` helper rejects `type_length` outside `1..=32` for 
both `LogicalType::Decimal` and `ConvertedType::DECIMAL`.
   - Inline `type_length == 12` check for `ConvertedType::INTERVAL`.
   
   # Are these changes tested?
   
   Yes. Five new tests in `parquet/src/arrow/schema/primitive.rs::tests` cover 
invalid lengths (`{-1, 0, 33}` for DECIMAL, `{0, 11, 13}` for INTERVAL) and 
valid lengths (16 → `Decimal128`, 32 → `Decimal256`, 12 → `Interval(DayTime)`). 
To exercise the reader-side check, tests construct a valid 
`Type::PrimitiveType` via the builder and rewrite `type_length` on the 
resulting enum, simulating a schema decoded from Thrift.
   
   # Are there any user-facing changes?
   
   No public API changes. The behavior change is reader-side: schemas with 
out-of-range `type_length` for DECIMAL/INTERVAL now return 
`ParquetError::General` instead of silently producing a wrong Arrow type.


-- 
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]

Reply via email to