fix: raise `ValidationError` for decimal precision outside range (#3585) Closes #3583 # Rationale for this change According to the Iceberg specification, decimal precision must be between 1 and 38. Previously, `pyiceberg` silently accepted invalid values (such as `precision=39` or `0`), which could lead to data corruption or crashes downstream when encoding/decoding fixed-byte decimals (matching the Java implementation's `IllegalArgumentException`). This PR adds a defensive validation guard into `DecimalType.__init__` to raise a `ValidationError` when the precision is out of bounds `[1, 38]`. Additionally, fixed an existing invalid type definition (`DecimalType(100, 2)`) inside `tests/test_schema.py` which was violating the specification bounds and causing the new validation guard to trip during the integration test suite. ## Are these changes tested? Yes, added dedicated unit tests in `tests/test_types.py`: - `test_decimal_precision_validation` covers upper bounds (`precision=39`), lower bounds (`precision=0`, `precision=-5`), and ensures valid boundary values (`precision=38`) work perfectly. Also updated existing test assertions in `tests/test_schema.py` to use a compliant precision value (`38`). ## Are there any user-facing changes? Yes, creating a `DecimalType` with an invalid precision will now explicitly raise a `pyiceberg.exceptions.ValidationError` instead of failing silently at runtime.
PyIceberg is a Python library for programmatic access to Iceberg table metadata as well as to table data in Iceberg format. It is a Python implementation of the Iceberg table spec.
The documentation is available at https://py.iceberg.apache.org/.