himadripal commented on code in PR #7177:
URL: https://github.com/apache/arrow-rs/pull/7177#discussion_r1973050216


##########
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:
   Now,  we can close this PR, as I added additional test in #7179  to check 
the values generated by `parse_string_to_decimal_native` and `parse_decimal` 
are same. So no change in existing test or coverage.



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

Reply via email to