viirya commented on code in PR #3711:
URL: https://github.com/apache/arrow-rs/pull/3711#discussion_r1106048286


##########
arrow-csv/src/reader/mod.rs:
##########
@@ -1318,7 +1339,7 @@ mod tests {
         let schema = Schema::new(vec![
             Field::new("city", DataType::Utf8, false),
             Field::new("lat", DataType::Decimal128(38, 6), false),
-            Field::new("lng", DataType::Decimal128(38, 6), false),
+            Field::new("lng", DataType::Decimal256(38, 6), false),

Review Comment:
   Maybe use a larger precision/scale for `Decimal256`.



##########
arrow-csv/src/reader/mod.rs:
##########
@@ -1788,20 +1826,20 @@ mod tests {
             ("-123.", -123000i128),
         ];
         for (s, i) in tests {
-            let result = parse_decimal_with_parameter(s, 20, 3);
+            let result = parse_decimal_with_parameter::<Decimal128Type>(s, 20, 
3);
             assert_eq!(i, result.unwrap())
         }
         let can_not_parse_tests = ["123,123", ".", "123.123.123"];
         for s in can_not_parse_tests {
-            let result = parse_decimal_with_parameter(s, 20, 3);
+            let result = parse_decimal_with_parameter::<Decimal128Type>(s, 20, 
3);
             assert_eq!(
                 format!("Parser error: can't parse the string value {s} to 
decimal"),
                 result.unwrap_err().to_string()
             );
         }
         let overflow_parse_tests = ["12345678", "12345678.9", "99999999.99"];
         for s in overflow_parse_tests {
-            let result = parse_decimal_with_parameter(s, 10, 3);
+            let result = parse_decimal_with_parameter::<Decimal128Type>(s, 10, 
3);

Review Comment:
   Perhaps adding test for `Decimal256Type`.



##########
arrow-csv/src/reader/mod.rs:
##########
@@ -781,22 +795,22 @@ fn parse_bool(string: &str) -> Option<bool> {
 }
 
 // parse the column string to an Arrow Array
-fn build_decimal_array(
+fn build_decimal_array<T: DecimalType>(

Review Comment:
   👍 



##########
arrow-csv/src/writer.rs:
##########
@@ -406,6 +408,59 @@ sed do eiusmod 
tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
         assert_eq!(expected.to_string(), String::from_utf8(buffer).unwrap());
     }
 
+    #[test]
+    fn test_write_csv_decimal() {
+        let schema = Schema::new(vec![
+            Field::new("c1", DataType::Decimal128(38, 6), true),
+            Field::new("c2", DataType::Decimal256(38, 6), true),

Review Comment:
   ditto. Maybe using larger precision/scale for Decimal256.



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