snoopuppy582 opened a new pull request, #11420: URL: https://github.com/apache/arrow-rs/pull/11420
# Which issue does this PR close? Follow-up to #10996. # Rationale for this change Decimal division can reject representable results when the divisor has a negative scale. For example, `0.1 / 10000` with input types `Decimal32(1, 1)` and `Decimal32(1, -4)` should produce `0.00001` at scale 5. Instead, the inferred precision is 1, and the result fails with `scale 5 is greater than precision 1`. # What changes are included in this PR? Calculate the inferred precision in a wider signed integer, then bound it by the minimum valid precision and the decimal type's maximum. The lower bound is 1 or the output scale, whichever is greater. Scale selection and coefficient arithmetic stay unchanged. # Are these changes tested? Two regressions cover all four decimal widths, separating the positive-scale constraint from the minimum precision of 1. They compare both coefficients and metadata, including signed values, zero, nulls and adjacent cases that already work. # Are there any significant user-facing changes? When the inferred precision was negative, the unsigned conversion could give a zero quotient the type's maximum precision. These results now use the minimum valid precision; their coefficients and scale are unchanged. AI assistance was used for the implementation, regression tests and this description. -- 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]
