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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to