Repository navigation
fix(json): return a parse error for a decimal precision above 38 - #1010
Closed
LuciferYang wants to merge 1 commit into
Closed
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
…alType TypeFromJson's decimal branch constructed DecimalType directly after regex-parsing the numbers; the constructor throws IcebergError via CHECK_OR_DIE when precision exceeds the supported maximum of 38, so a schema string like "decimal(39, 2)" escaped the Result error contract as an uncaught exception. Check the range first and return JsonParseError, keeping malformed schema JSON inside the parse-error model.
zhjwpku
approved these changes
Oct 14, 2026
zhjwpku
left a comment
Collaborator
There was a problem hiding this comment.
LGTM.
Just wondering, was this discovered through cross-engine testing?
Contributor
Author
|
Thanks for the review, @zhjwpku. To answer your question: no, this came from reading the parser, not from a cross-engine run. Looking at it again, the only input that reaches this path is a metadata file with a decimal precision above 38, which no conforming writer produces, so it hardens against malformed metadata rather than fixing something users run into. I'm closing it to keep the focus on reproducible issues. |
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.
What
TypeFromJsonbuiltDecimalTypestraight from the regex-parsed precision. The constructor throwsIcebergErrorfor a precision above 38, so a type string such as"decimal(39, 2)"threw out of aResult-returning parser instead of producing aJsonParseError. This reaches table-metadata reads and REST bodies that carry a schema.Closes #1009.
How
Return
JsonParseErrorwhen the parsed precision exceedsDecimalType::kMaxPrecision, before the type is constructed. The regex only captures digits andParseNumberrejects int32 overflow, so no lower-bound check is needed.Testing
TypeJsonTest.FromJsonOutOfRangeDecimalPrecisionIsParseErrorparses"decimal(39, 2)"and expectskJsonParseError. Without the fix it fails withDecimalType: precision must be in [0, 38], was 39thrown in the test body.