gruuya opened a new issue, #9422: URL: https://github.com/apache/arrow-rs/issues/9422
**Describe the bug** The [fix](https://github.com/apache/arrow-rs/pull/8700) that corrected the decimal position spillover when parsing zero scale numbers also introduced another issue, which is that it always truncates the number instead of rounding it appropriately. **To Reproduce** The following test case fails, instead the parsed number is `1`. ```rust assert_eq!( parse_decimal::<Decimal128Type>("1.9", 3, 0).unwrap(), 2, ); ``` **Expected behavior** It's not instantly clear that this should be the expected behavior in this case, but it would make sense to align with Postgres and DuckDB, where this is true ```sql postgres@localhost:postgres> select '1.1'::numeric(3, 0), '1.9'::numeric(3, 0); +---------+---------+ | numeric | numeric | |---------+---------| | 1 | 2 | +---------+---------+ ``` ```sql D select '1.1'::numeric(3, 0), '1.9'::numeric(3, 0); ┌─────────────────────────────┬─────────────────────────────┐ │ CAST('1.1' AS DECIMAL(3,0)) │ CAST('1.9' AS DECIMAL(3,0)) │ │ decimal(3,0) │ decimal(3,0) │ ├─────────────────────────────┼─────────────────────────────┤ │ 1 │ 2 │ └─────────────────────────────┴─────────────────────────────┘ ``` **Additional context** Note that the behavior is as expected when the decimal part is less than `.5`, since truncation and rounding then match up. -- 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]
