neilconway opened a new pull request, #10864:
URL: https://github.com/apache/arrow-rs/pull/10864

   # Which issue does this PR close?
   
   - Closes #10863.
   
   # Rationale for this change
   
   `make_comparator` accepted decimal arrays with different scales and compared 
their raw, unscaled values. This yields incorrect results.
   
   Instead, reject such inputs, as we do for other instances of incomparable 
types. There isn't a clean way to do this inside the existing per-type 
`downcast_primitive!` structure (since that discards the scale), so add a check 
on the scale before we match on the array type.
   
   Note that precision is not required to match: precision only bounds what can 
be stored in a given decimal value, it does not influence the actual bitwise 
representation of a decimal value.
   
   Most downstream systems will avoid calling `make_comparator` on decimals 
with mismatched scales, but if this situation does occur, an error is much 
better than silently returning incorrect results.
   
   # What changes are included in this PR?
   
   See above.
   
   # Are these changes tested?
   
   Yes; new tests added.
   
   # Are there any user-facing changes?
   
   No. (Previously allowed inputs to `make_comparator` will now be rejected, 
but such inputs did not yield a sensible result in the past.)
   
   # AI usage
   
   Claude Code Fable 5 found the bug and wrote the fix; I reviewed, edited, and 
understand the resulting code.


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