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


##########
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:
   if I combining #7179 with this one, result is no change. #7179 add the 
feature of adding scale 0 support in parse decimal and also introduces rounding 
behavior. Shall I combine #7179 with this refactor. What is your thought?



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