Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the decimal parsing and precision-validation changes.
No open issues 🎉
What changed in this PR
Fixes decimal parsing in Iceberg’s value layer to address #3654: positive exponents are preserved, and oversized coefficients are rejected before conversion to i128.
Changes:
- Centralizes checked decimal coefficient extraction with scale and precision validation.
- Validates JSON decimal precision after rounding to the target scale.
- Adds regression coverage for exponent handling, oversized values, and JSON scale conversion.
| File | Description |
|---|---|
crates/iceberg/src/writer/file_writer/parquet_writer.rs |
Updates test calls for fallible coefficient extraction. |
crates/iceberg/src/spec/values/tests.rs |
Adds decimal parsing and precision regression tests. |
crates/iceberg/src/spec/values/literal.rs |
Uses checked extraction for string and JSON decimals. |
crates/iceberg/src/spec/values/decimal_utils.rs |
Applies exponents and validates precision before conversion. |
crates/iceberg/src/spec/values/datum.rs |
Routes decimal constructors through shared validation. |
Review effort: Balanced
This branch has not been deployed
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.
Which issue does this PR close?
What changes are included in this PR?
Apply positive exponents before extracting the unscaled decimal value, so
1e3produces1000. Validate precision before converting the coefficient toi128, so oversized inputs returnDataInvalidinstead of silently producing an incorrect value. JSON decimal parsing also validates the declared precision after rounding to the target scale.Are these changes tested?
Added three regression tests covering positive exponents, the 38-digit precision boundary, and precision validation at the target JSON scale. All three failed before the fix and passed after it.
AI Disclosure