huan233usc opened a new pull request, #809: URL: https://github.com/apache/iceberg-cpp/pull/809
## What `SchemaField::Validate` accepts a decimal default whose unscaled value does not fit the field's declared precision, even though the JSON reader rejects exactly that value on read-back — so a validated field can serialize to metadata that the same reader then refuses to parse. Example: a `decimal(2, 1)` field with an `initial-default` of `Literal::Decimal(999, 2, 1)` (`99.9`, which needs 3 significant digits). `ValidateDefault` only checked that the literal's type matches the field type (`decimal(2,1) == decimal(2,1)`), so it passed; the value was serialized to `"99.9"`; on read-back `Decimal::FromString` yields precision 3 > 2 and the decimal literal parser (`expression/json_serde.cc`, and `Literal::CastTo`) rejects it. The field's own metadata becomes unreadable. ## How `ValidateDefault` now checks `Decimal::FitsInPrecision(field precision)` for decimal defaults after the type-equality check, rejecting an out-of-range value up front so it is consistent with what the reader accepts. This mirrors the same guard already applied when casting defaults during schema evolution. ## Testing `SchemaFieldTest.ValidateRejectsDecimalDefaultExceedingPrecision` (rejects `99.9` for `decimal(2,1)`) and `ValidateAcceptsDecimalDefaultWithinPrecision` (accepts a fitting value), verified fail-without / pass-with. Full `schema_test` passes (551 tests). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
