dragonknightk opened a new pull request, #515: URL: https://github.com/apache/arrow-dotnet/pull/515
## What's Changed Shredding a variant into a `Decimal16` column threw `InvalidCastException`. `VariantShredder` extracts those values as `SqlDecimal`, but `ShreddedVariantArrayBuilder.Build` always cast them to `System.Decimal`. It also read the column scale only from `System.Decimal` values, so a `Decimal16` column would have got scale 0. `VariantUnshredder.Reconstruct` had the same cast and threw for every `Decimal16` typed value from the shredder. `BuildDecimalArray` now takes the scale from `SqlDecimal` values too, and appends them with `Decimal128Array.Builder.Append(SqlDecimal)` so values outside the `System.Decimal` range stay exact. `CreateVariantFromTyped` now passes a `SqlDecimal` to `FromDecimal16`, and keeps a `System.Decimal` fallback for callers that still pass that type. The new test `Primitive_Decimal16` builds `Decimal16` rows with different scales, including one value outside the `System.Decimal` range. It checks the column is `Decimal128(38, 3)` and every value keeps its exact digits, then round-trips through the reader. `Reconstruct_Decimal16` covers the unshred path with a value outside the `System.Decimal` range, and a `System.Decimal` input that takes the compatibility fallback. `ShredSchema.FromArrowType` dropping the precision and scale of `Decimal128Type` is a separate problem and is not changed here. Closes #498. ## AI Disclosure Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. -- 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]
