Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes PyIceberg’s decimal type parsing more permissive by allowing optional whitespace around decimal parameters, aligning behavior with other Iceberg language implementations.
Changes:
- Update the decimal type parsing regex to tolerate whitespace around precision/scale and separators.
- Add unit tests covering multiple whitespace variants for
decimal(P,S)JSON deserialization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_types.py | Adds parametrized tests to ensure DecimalType deserialization accepts optional whitespace variants. |
| pyiceberg/types.py | Relaxes the decimal parsing regex to allow whitespace around precision/scale and punctuation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from pyiceberg.utils.singleton import Singleton | ||
|
|
||
| DECIMAL_REGEX = re.compile(r"decimal\((\d+),\s*(\d+)\)") | ||
| DECIMAL_REGEX = re.compile(r"decimal\(\s*(\d+)\s*,\s*(\d+)\s*\)") |
| DECIMAL_REGEX = re.compile(r"decimal\((\d+),\s*(\d+)\)") | ||
| DECIMAL_REGEX = re.compile(r"decimal\(\s*(\d+)\s*,\s*(\d+)\s*\)") | ||
| FIXED = "fixed" | ||
| FIXED_PARSER = ParseNumberFromBrackets(FIXED) |
There was a problem hiding this comment.
Should we align this logic to the other regex too?
private static final Pattern FIXED = Pattern.compile("fixed\\[\\s*(\\d+)\\s*\\]");
private static final Pattern GEOMETRY_PARAMETERS =
Pattern.compile("geometry\\s*(?:\\(\\s*([^)]*?)\\s*\\))?", Pattern.CASE_INSENSITIVE);
private static final Pattern GEOGRAPHY_PARAMETERS =
Pattern.compile(
"geography\\s*(?:\\(\\s*([^,]*?)\\s*(?:,\\s*(\\w*)\\s*)?\\))?", Pattern.CASE_INSENSITIVE);
private static final Pattern DECIMAL =
Pattern.compile("decimal\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)");|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
@sungwy can you make the proposed changes and we can hopefully get this merged in? |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
|
@sungwy this was closed by the stale bot on 29 August rather than on merit — @rambleraptor had asked on 21 July to make the review changes so it could be merged. Would you reopen it? I dug into @geruh's request to align the other regexes and it turns out to be more than tidying, so I think this PR is worth more than it looked. On current
The geospatial rows are the ones I did not expect. A detail that makes this concrete: the geospatial fixtures in apache/iceberg-verification#9 already spell "unquoted" into their clauses ( Happy to help either way — reopen and I can push the remaining pieces to your branch, or if you would rather not carry it, I can open a successor PR with your commit preserved and credited. Your call; I would rather not step on it. |
|
yup was trying to nudge in this direction... |
Reference: apache/iceberg#16798
Rationale for this change
PyIceberg is a bit more strict in its parsing than the other language implementations. This allows json string representations like
decimal( 9, 2 )like the other libraries.Are these changes tested?
Unit tested
Are there any user-facing changes?
Yes, more permissive metadata parsing by PyIceberg clients.