Skip to content

fix: return an error for decimal precision above 38 in TypeFromJson - #1147

Open
WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix/decimal-precision-error
Open

WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix/decimal-precision-error

Conversation

@WZhuo

@WZhuo WZhuo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1143.

TypeFromJson passed the parsed precision straight to the DecimalType constructor. When the precision is above 38, the constructor's ICEBERG_CHECK_OR_DIE throws IcebergError. So "decimal(39,0)", or a schema or table metadata containing it, threw instead of returning an error.

This checks the precision against DecimalType::kMaxPrecision before constructing the type, and returns a JsonParseError like the existing one for a malformed decimal string.

TypeJsonTest.InvalidV2Types collects the error cases for the v1 and v2 types: decimal precision above 38, malformed decimal and fixed strings, an unknown type name, struct, list and map objects missing a required key, and an unknown complex type. Each must return a JsonParseError. It also checks that a schema with a decimal(39, 0) field fails through SchemaFromJson instead of throwing.

The iceberg-verification case types/primitive/decimal-precision-over-38 (#1144) passes with this change.

@WZhuo
WZhuo marked this pull request as draft November 19, 2026 04:06
@WZhuo
WZhuo force-pushed the fix/decimal-precision-error branch 4 times, most recently from 58ce6a2 to 4d4f216 Compare November 20, 2026 04:34
@WZhuo
WZhuo marked this pull request as ready for review November 20, 2026 04:37
TypeFromJson passed the parsed precision straight to the DecimalType
constructor, whose ICEBERG_CHECK_OR_DIE throws IcebergError when the
precision exceeds 38. A type string such as "decimal(39,0)", or a schema
or table metadata containing one, threw instead of returning an error.

Check the precision against DecimalType::kMaxPrecision before
constructing the type and return a JsonParseError.

Closes apache#1143.
@WZhuo
WZhuo force-pushed the fix/decimal-precision-error branch from 4d4f216 to e216823 Compare November 20, 2026 05:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeFromJson throws on decimal precision above 38 instead of returning an error

1 participant