You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "PLTNGM (via GitHub)" <gi...@apache.org> on 2026/06/29 15:28:15 UTC
[PR] fix: raise ValidationError for decimal precision outside 1-38 range [iceberg-python]
PLTNGM opened a new pull request, #3585:
URL: https://github.com/apache/iceberg-python/pull/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]`.
## 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.
## 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.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: raise ValidationError for decimal precision outside 1-38 range [iceberg-python]
Posted by "PLTNGM (via GitHub)" <gi...@apache.org>.
PLTNGM commented on PR #3585:
URL: https://github.com/apache/iceberg-python/pull/3585#issuecomment-5015514172
> This looks good to me. I like the Pydantic approach. I'll go ahead and merge this 👍
Thanks!
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: raise ValidationError for decimal precision outside 1-38 range [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #3585:
URL: https://github.com/apache/iceberg-python/pull/3585
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org