liukun4515 commented on code in PR #3224:
URL: https://github.com/apache/arrow-rs/pull/3224#discussion_r1034520827


##########
arrow-cast/src/cast.rs:
##########
@@ -2139,10 +2140,23 @@ fn cast_decimal_to_decimal<const BYTE_WIDTH1: usize, 
const BYTE_WIDTH2: usize>(
                             *output_scale,
                         ))
                     })?;
+                let half = div / 2;
+                let neg_half = -half;
 
                 array
                     .try_unary::<_, Decimal128Type, _>(|v| {
-                        v.checked_div(div).ok_or_else(|| {
+                        // cast to smaller scale, need to round the result
+                        // the div must be gt_eq 10, we don't need to check 
the overflow for the `div`/`mod` operation
+                        let d = v / div;

Review Comment:
   Do we need to make consistent with the usage and clear compilation result? 



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