viirya commented on code in PR #3690:
URL: https://github.com/apache/arrow-rs/pull/3690#discussion_r1137570366
##########
arrow-arith/src/arithmetic.rs:
##########
@@ -1165,6 +1168,78 @@ pub fn multiply_dyn_checked(
}
}
+/// Perform `left * right` operation on two decimal arrays. If either left or
right value is
+/// null then the result is also null.
+///
+/// This performs decimal multiplication which allows precision loss if an
exact representation
+/// is not possible for the result, according to the required scale. In the
case, the result
+/// will be rounded to the required scale.
+///
+/// If the required scale is greater than the product scale, an error is
returned.
+///
+/// It is implemented for compatibility with precision loss `multiply`
function provided by
+/// other data processing engines. For multiplication with precision loss
detection, use
+/// `multiply` or `multiply_checked` instead.
+pub fn mul_fixed_point_checked(
+ left: &PrimitiveArray<Decimal128Type>,
+ right: &PrimitiveArray<Decimal128Type>,
+ required_scale: i8,
+) -> Result<PrimitiveArray<Decimal128Type>, ArrowError> {
+ let product_scale = left.scale() + right.scale();
+
+ if required_scale == product_scale {
+ return multiply_checked(left, right);
Review Comment:
There is a test for `required_scale == product_scale` case. I just need to
remove `with_precision_and_scale` in the test.
--
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]