You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "gitcommit90 (via GitHub)" <gi...@apache.org> on 2026/06/29 15:16:54 UTC
[PR] fix: reject DecimalType with precision outside [1, 38] [iceberg-python]
gitcommit90 opened a new pull request, #3584:
URL: https://github.com/apache/iceberg-python/pull/3584
The [Iceberg spec](https://iceberg.apache.org/spec/#primitive-types) states precision must be 38 or less (minimum 1). The Python library silently accepted any precision value; `DecimalType(39, 0)` succeeded with no error, which can corrupt downstream fixed-byte decimal encoding.
The Java reference implementation rejects it: `DecimalType.of(39, 0)` raises `IllegalArgumentException`.
**Fix:** Add a 2-line guard in `DecimalType.__init__` that raises `pyiceberg.exceptions.ValidationError` when `precision < 1` or `precision > 38`. Uses the same exception class and pattern already used throughout `pyiceberg/types.py`.
**Tests added (4 new):**
- `test_decimal_precision_above_38_raises` — precision=39 raises
- `test_decimal_precision_zero_raises` — precision=0 raises
- `test_decimal_precision_boundary_38_accepted` — precision=38 accepted
- `test_decimal_deserialization_precision_above_38_raises` — deserialization path also raises
All 292 existing tests pass; ruff clean.
closes #3583
--
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: reject DecimalType with precision outside [1, 38] [iceberg-python]
Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on PR #3584:
URL: https://github.com/apache/iceberg-python/pull/3584#issuecomment-4919505835
@gitcommit90 are you able to make these quick changes? I'd love to get this in before 0.12
--
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: reject DecimalType with precision outside [1, 38] [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko closed pull request #3584: fix: reject DecimalType with precision outside [1, 38]
URL: https://github.com/apache/iceberg-python/pull/3584
--
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: reject DecimalType with precision outside [1, 38] [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #3584:
URL: https://github.com/apache/iceberg-python/pull/3584#issuecomment-5012798252
With the upcoming release, I've merged the Pydantic approach suggested in https://github.com/apache/iceberg-python/pull/3585. This makes this PR now obsolete. Nevertheless thanks @gitcommit90 for working on this. As a suggestion, it would be good to follow up more quickly to get things in.
--
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: reject DecimalType with precision outside [1, 38] [iceberg-python]
Posted by "rambleraptor (via GitHub)" <gi...@apache.org>.
rambleraptor commented on code in PR #3584:
URL: https://github.com/apache/iceberg-python/pull/3584#discussion_r3531237425
##########
pyiceberg/table/__init__.py:
##########
@@ -2471,8 +2471,9 @@ def plan_files(self) -> Iterable[FileScanTask]:
options=self.options,
).plan_files(
manifests=manifests,
- manifest_entry_filter=lambda manifest_entry: manifest_entry.snapshot_id in append_snapshot_ids
Review Comment:
This looks stray. Can you remove this?
##########
pyiceberg/types.py:
##########
@@ -324,6 +324,8 @@ class DecimalType(PrimitiveType):
root: tuple[int, int]
def __init__(self, precision: int, scale: int) -> None:
+ if not (1 <= precision <= 38):
+ raise ValidationError(f"Precision must be between 1 and 38 (inclusive), got: {precision}")
Review Comment:
+1. This is how we do validations elsewhere in the code as well.
--
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