himadripal commented on code in PR #6836:
URL: https://github.com/apache/arrow-rs/pull/6836#discussion_r1870661505


##########
arrow-cast/src/cast/decimal.rs:
##########
@@ -155,28 +163,24 @@ where
     T: DecimalType,
     T::Native: DecimalCast + ArrowNativeTypeOp,
 {
-    let array: PrimitiveArray<T> = match input_scale.cmp(&output_scale) {
-        Ordering::Equal => {
-            // the scale doesn't change, the native value don't need to be 
changed
-            array.clone()
-        }
-        Ordering::Greater => convert_to_smaller_scale_decimal::<T, T>(
-            array,
-            input_scale,
-            output_precision,
-            output_scale,
-            cast_options,
-        )?,
-        Ordering::Less => {
-            // input_scale < output_scale
+    let array: PrimitiveArray<T> = if input_scale <= output_scale {
+            // input_scale <= output_scale
+            // the scale doesn't change, but precision may change and cause 
overflow

Review Comment:
   Yes, you are right.   fn signature only has output_precision, I can get the 
input_precision from the calling fn, it's available there and change the 
signature. would that be fine?



##########
arrow-cast/src/cast/decimal.rs:
##########
@@ -155,28 +163,24 @@ where
     T: DecimalType,
     T::Native: DecimalCast + ArrowNativeTypeOp,
 {
-    let array: PrimitiveArray<T> = match input_scale.cmp(&output_scale) {
-        Ordering::Equal => {
-            // the scale doesn't change, the native value don't need to be 
changed
-            array.clone()
-        }
-        Ordering::Greater => convert_to_smaller_scale_decimal::<T, T>(
-            array,
-            input_scale,
-            output_precision,
-            output_scale,
-            cast_options,
-        )?,
-        Ordering::Less => {
-            // input_scale < output_scale
+    let array: PrimitiveArray<T> = if input_scale <= output_scale {
+            // input_scale <= output_scale
+            // the scale doesn't change, but precision may change and cause 
overflow

Review Comment:
   Yes, you are right.   fn signature only has output_precision, I can get the 
input_precision from the calling fn, it's available there and change the 
signature to include input_precision. would that be fine?



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