huan233usc opened a new pull request, #805: URL: https://github.com/apache/iceberg-cpp/pull/805
## What Add casting of integer literals (`int` / `long`) to a decimal target type in `Literal::CastTo`, so that an integer can be used as a default value for a decimal column. Previously `CastFromInt` / `CastFromLong` had no `kDecimal` case and fell through to `NotSupported`, so a default like `Literal::Int(12)` for a `decimal(9, 2)` column was rejected. Java allows this (`IntegerLiteral.to(decimal)` / `LongLiteral.to(decimal)` scale the value to the target scale), so this brings the C++ literal cast layer to parity for integer sources. ## How `CastIntegerToDecimal` scales the integer (scale 0) up to the target scale via `Decimal::Rescale(0, scale)` — which rejects a scale that would overflow — then verifies the result fits the target precision with `FitsInPrecision`, rejecting out-of-range values with `InvalidArgument`. Example: `12` cast to `decimal(9, 2)` yields the decimal with unscaled value `1200` (i.e. `12.00`). ## Scope This is a follow-up split out from the v3 default-value work (see the `CastDefaultToType` discussion on #793). It only extends the shared `Literal::CastTo` layer for integer sources; `float` / `double` → decimal is a separate follow-up (C++ has no real→decimal helper yet). ## Testing `LiteralTest.IntegerCastToDecimal` covers int→decimal and long→decimal scaling and the out-of-precision rejection, verified fail-without / pass-with the change. Full `expression_test` passes (494 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]
