kratos0718 opened a new pull request, #3593:
URL: https://github.com/apache/iceberg-python/pull/3593

   ## Summary
   
   The Iceberg [spec](https://iceberg.apache.org/spec/#primitive-types) 
requires decimal precision to be **38 or less** ("Scale is fixed, precision 
must be 38 or less"). Currently `DecimalType(39, 0)` — and parsing the type 
string `"decimal(39, 0)"` — is accepted silently, producing 
`DecimalType(precision=39, scale=0)`. Precision above 38 isn't representable in 
decimal's fixed-byte storage, so silently accepting it can corrupt downstream 
encoding.
   
   The Java reference implementation rejects this: `DecimalType.of(39, 0)` 
raises `IllegalArgumentException: Decimals with precision larger than 38 are 
not supported: 39`.
   
   Closes #3583.
   
   ## Change
   
   Validate `precision <= 38` in `DecimalType.__init__`, raising `ValueError` 
with the same message as the Java reference. This covers both direct 
construction and the string-parse path (`_parse_decimal_type` constructs 
`DecimalType(precision, scale)`, which routes through `__init__`).
   
   ## Test
   
   Added `test_decimal_type_rejects_precision_over_38`: `DecimalType(39, 0)` 
raises, and the boundary `DecimalType(38, 0)` remains valid.


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