himadripal commented on code in PR #7177:
URL: https://github.com/apache/arrow-rs/pull/7177#discussion_r1972248582
##########
arrow-cast/src/cast/decimal.rs:
##########
@@ -590,43 +590,34 @@ where
#[cfg(test)]
mod tests {
use super::*;
+ use crate::parse::parse_decimal;
#[test]
fn test_parse_string_to_decimal_native() -> Result<(), ArrowError> {
- assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("0", 0)?,
- 0_i128
- );
- assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("0", 5)?,
- 0_i128
- );
+ assert_eq!(parse_decimal::<Decimal128Type>("0", 38, 0)?, 0_i128);
+ assert_eq!(parse_decimal::<Decimal128Type>("0", 38, 5)?, 0_i128);
+ assert_eq!(parse_decimal::<Decimal128Type>("123", 38, 0)?, 123_i128);
assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("123", 0)?,
- 123_i128
- );
- assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("123", 5)?,
+ parse_decimal::<Decimal128Type>("123", 38, 5)?,
12300000_i128
);
+ // `parse_decimal` does not handle scale=0 correctly. will enable it
as part of code change PR.
+ // assert_eq!(parse_decimal::<Decimal128Type>("123.45", 38, 0)?,
123_i128);
assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("123.45", 0)?,
- 123_i128
- );
- assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("123.45", 5)?,
+ parse_decimal::<Decimal128Type>("123.45", 38, 5)?,
12345000_i128
);
- assert_eq!(
- parse_string_to_decimal_native::<Decimal128Type>("123.4567891",
0)?,
+ //scale = 0 is not handled correctly in parse_decimal, next PR will
fix it and enable this.
Review Comment:
So, this is commented as parse_decimal do not have handling of scale 0 well,
this is fixed in the #7191 and this test is enabled there - all of these
changes are all together in #6905
--
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]