mikamikasuki opened a new pull request, #55246:
URL: https://github.com/apache/arrow/pull/55246

   ### Rationale for this change
   
   Safe decimal casts to Decimal32 can silently change values or reject exact 
conversions because the input coefficient is narrowed before rescaling and 
precision checks.
   
   ### What changes are included in this PR?
   
   Keep wider input decimals at their source width during safe rescaling, then 
narrow to Decimal32 only after the target precision check succeeds.
   
   Fixes #53288.
   
   ### Are these changes tested?
   
   Added regression cases for overflow, negative-scale exact rescaling, and 
fractional-scale exact rescaling. The regression fails with the previous 
conversion path and passes with this change. The full 
`arrow-compute-scalar-cast-test` executable passes (108 tests).
   
   ### Are there any user-facing changes?
   
   Safe casts now return the correct value or an overflow error. No public API 
changes.
   
   **This PR contains a "Critical Fix".** Safe casts could previously return an 
incorrect decimal value or reject an exact conversion.
   
   ### Was AI used for this PR?
   
   OpenAI Codex assisted with investigation, implementation, regression-test 
development, and review. The new tests were run against current main 
(`2c800e6`) before and after the fix.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [x] AI
   - [ ] Not reviewed


-- 
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]

Reply via email to