dayan02dev opened a new pull request, #12242: URL: https://github.com/apache/arrow-rs/pull/12242
# Which issue does this PR close? - Closes #11300 # Rationale for this change `null_if_overflow_precision` returned the default type of the decimal width instead of the input's type. A `Decimal128(2, 1)` holding `9.9` came back as `Decimal128(38, 10)` and read as `0.0000000099`. All four decimal widths behave this way, because the result is built through `unary_opt`, which uses `T::DATA_TYPE`. #11310 and #11321 fixed the same kind of bug. # What changes are included in this PR? - Set the input's data type on the `unary_opt` result with `.with_data_type(self.data_type().clone())`, as `into_builder` does since #11321. # Are these changes tested? Yes. `test_null_if_overflow_precision_keeps_data_type` covers Decimal32/64/128/256 at `(2, 1)`. Without the fix it fails with `Decimal32(9, 2)` vs `Decimal32(2, 1)`. # Are there any significant user-facing changes? The output data type now matches the input, including precision and scale. Which values get nulled is unchanged. Callers that re-applied the type afterwards (for example with `.with_precision_and_scale(..)`) keep working. # AI usage disclosure The patch and test were written with an AI coding agent (Claude Code). It reproduced the issue on main, ran fmt, clippy, the arrow-array tests (including release mode) and typos, and a separate agent session re-checked the fix against all four decimal widths, nulls, slices and the precision bounds before I submitted it. -- 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]
