Fix decimal physicial type mapping#1839
Merged
Fokko merged 5 commits intoapache:mainfrom Mar 31, 2025
Merged
Conversation
Contributor
Author
|
Hi @kevinjqliu @Fokko
|
Closed
Fokko
reviewed
Mar 31, 2025
Contributor
Fokko
left a comment
There was a problem hiding this comment.
Thanks @redpheonixx for working on this! 🙌 I think we're very close, I left one comment to simplify it a bit further. Let me know what you think!
pyiceberg/io/pyarrow.py
Outdated
Comment on lines
2355
to
2363
Contributor
There was a problem hiding this comment.
I think we can simplify this into:
Suggested change
| precision = stats_col.iceberg_type.precision | |
| scale = stats_col.iceberg_type.scale | |
| decimal_type = pa.decimal128(precision, scale) | |
| col_aggs[field_id].update_min( | |
| pa.array([Decimal(statistics.min_raw) / (10**scale)], decimal_type)[0].as_py() | |
| ) | |
| col_aggs[field_id].update_max( | |
| pa.array([Decimal(statistics.max_raw) / (10**scale)], decimal_type)[0].as_py() | |
| ) | |
| scale = stats_col.iceberg_type.scale | |
| col_aggs[field_id].update_min(unscaled_to_decimal(statistics.min_raw, scale)) | |
| col_aggs[field_id].update_max(unscaled_to_decimal(statistics.max_raw, scale)) |
We already have the unscale_to_decimal that we can import from pyiceberg.utils.decimal.
Contributor
Author
There was a problem hiding this comment.
Hi @Fokko ,
thanks for the comment
I have updated the code and used unscale_to_decimal now
Fokko
approved these changes
Mar 31, 2025
Contributor
|
Thanks for fixing this @redpheonixx 🙌 |
Fokko
pushed a commit
that referenced
this pull request
Apr 17, 2025
This pull request addresses the handling of decimal physical type matching in Parquet. It implements rules such that: For precision ≤ 9, values are stored as `int32`. For precision ≤ 18, values are stored as `int64`. For higher precision, values are stored as a `FIXED_LEN_BYTE_ARRAY`. Closes #1789 --------- Co-authored-by: redpheonixx <amitsingh@192.168.1.5> Co-authored-by: redpheonixx <amitsingh@192.168.1.10>
3 tasks
gabeiglio
pushed a commit
to Netflix/iceberg-python
that referenced
this pull request
Aug 13, 2025
This pull request addresses the handling of decimal physical type matching in Parquet. It implements rules such that: For precision ≤ 9, values are stored as `int32`. For precision ≤ 18, values are stored as `int64`. For higher precision, values are stored as a `FIXED_LEN_BYTE_ARRAY`. Closes apache#1789 --------- Co-authored-by: redpheonixx <amitsingh@192.168.1.5> Co-authored-by: redpheonixx <amitsingh@192.168.1.10>
1 task
kevinjqliu
pushed a commit
that referenced
this pull request
Oct 26, 2025
<!--
Thanks for opening a pull request!
-->
<!-- In the case this PR will resolve an issue, please replace
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
<!-- Closes #${GITHUB_ISSUE_ID} -->
# Rationale for this change
Fix for #2057. It looks
like the initial fix #1839
might have missed updating here to handle. I could use feedback on if
this is the best fix, it is at least simple.
## Are these changes tested?
- [x] added unit tests
## Are there any user-facing changes?
No
<!-- In the case of user-facing changes, please add the changelog label.
-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses the handling of decimal physical type matching in Parquet. It implements rules such that:
For precision ≤ 9, values are stored as
int32.For precision ≤ 18, values are stored as
int64.For higher precision, values are stored as a
FIXED_LEN_BYTE_ARRAY.Closes #1789