You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Dandandan (via GitHub)" <gi...@apache.org> on 2023/02/01 09:41:03 UTC

[GitHub] [arrow-rs] Dandandan opened a new issue, #3645: Multiplication for decimals is incorrect

Dandandan opened a new issue, #3645:
URL: https://github.com/apache/arrow-rs/issues/3645

   **Describe the bug**
   Multiplication for decimals is wrong for decimals 
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   ```
       #[test]
       fn test_decimal_multiplication() {
           let a = Decimal128Array::from_iter_values([1]).with_precision_and_scale(1, 1).unwrap();
           
           let b = Decimal128Array::from_iter_values([1]).with_precision_and_scale(1, 1).unwrap();
   
           let e = Decimal128Array::from_iter_values([1]).with_precision_and_scale(2, 2).unwrap();
           let r = multiply(&a, &b).unwrap();
           assert_eq!(e, r);
       }
   ```
   0.1 * 0.1 should return 0.01.
   
   The current kernel just multiplies the raw integers but ignores the scale/precision values of the.
   
   ```
     left: `PrimitiveArray<Decimal128(2, 2)>
   [
     1,
   ]`,
    right: `PrimitiveArray<Decimal128(38, 10)>
   [
     1,
   ]`', arrow-arith/src/arithmetic.rs:2958:9
   
   ```
   
   **Expected behavior**
   The kernel should add scale as well, values 0.1 * 0.1 should have primitive value `1` with scale `2`.
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


-- 
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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] Dandandan commented on issue #3645: Multiplication for decimals is incorrect

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on issue #3645:
URL: https://github.com/apache/arrow-rs/issues/3645#issuecomment-1411771779

   Probably we don't expect the kernels in arrow-rs to handle this (but should do it in datafusion).


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] Dandandan closed issue #3645: Multiplication for decimals is incorrect

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan closed issue #3645: Multiplication for decimals is incorrect
URL: https://github.com/apache/arrow-rs/issues/3645


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org