You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "gruuya (via GitHub)" <gi...@apache.org> on 2024/11/13 12:40:28 UTC

[I] Negative decimal e-notation parsing bug [arrow-rs]

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

   **Describe the bug**
   Parsing negative decimal numbers in e-notation has a bug, whereby the parsed values is magnified by an order of magnitude (leading to potential false overflows).
   
   **To Reproduce**
   Run the following test (e.g. in `arrow-cast/src/parse.rs`)
   ```rust
       #[test]
       fn test_negative_decimal_e_notation() {
           assert_eq!(
               parse_decimal::<Decimal128Type>("-1e3", 38, 6).unwrap(),
               -1000000000i128,
           );
   
           assert_eq!(
               parse_decimal::<Decimal128Type>("-1e31", 38, 6).unwrap(),
               -10000000000000000000000000000000000000i128,
           );
       }
   ```
   The first assertion will fail, as the parsed value is erroneously `-11000000000`, while the second example will panic with `parse decimal overflow (-1e31)`, even though the value fits in the specified precision/scale range.
   
   **Expected behavior**
   The first test case above should return `-1000000000i128` (i.e. 3 zeros from `e3` + additional 6 zeros from the scale).
   
   The seconds case shouldn't overflow and should instead return `-10000000000000000000000000000000000000i128` (i.e. 31 zeros from `e31` + additional 6 zeros from the scale).
   
   **Additional context**


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


Re: [I] Signed decimal e-notation parsing bug [arrow-rs]

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

   `label_issue.py` automatically added labels {'arrow'} from #6729


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


Re: [I] Signed decimal e-notation parsing bug [arrow-rs]

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia closed issue #6728: Signed decimal e-notation parsing bug
URL: https://github.com/apache/arrow-rs/issues/6728


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