vera-rubin opened a new pull request, #1655: URL: https://github.com/apache/arrow-go/pull/1655
### Rationale for this change With `AllowDecimalTruncate` enabled, casting decimal128 or decimal256 `[1.9, -1.9]` to int64 returns `[2, -2]`. Truncation should drop the fractional digits and return `[1, -1]`, as the [CastOptions documentation](https://arrow.apache.org/docs/python/generated/pyarrow.compute.CastOptions.html) describes for `allow_decimal_truncate`. Unsafe casts (`NewCastOptions(..., false)`) set the same flag and round the same way. ### What changes are included in this PR? The decimal128 and decimal256 to integer kernels now call `ReduceScaleBy(inScale, false)` instead of `ReduceScaleBy(inScale, true)` when truncation is allowed, so the fractional digits are discarded instead of rounded. The safe path (truncation not allowed) is unchanged and still rejects these inputs. ### Are these changes tested? Yes. `TestCasts/TestDecimalToIntTruncateTowardZero` casts `["1.9", "-1.9", "1.5", "-1.5", "0.9", "-0.9", "1.1", "-1.1", "0.0", null]` from decimal128(2, 1) and decimal256(2, 1) to int64. It checks that the safe cast fails, and that with `AllowDecimalTruncate` (both safe and unsafe options) the result is `[1, -1, 1, -1, 0, 0, 1, -1, 0, null]`. The test fails without the fix and passes with it; the `./arrow/compute/...` tests pass. ### Are there any user-facing changes? Yes. Decimal-to-integer casts with truncation allowed (including unsafe casts) now truncate toward zero instead of rounding, so values such as `1.5` or `-1.9` give `1` and `-1` instead of `2` and `-2`. -- 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]
