sum12 commented on a change in pull request #1301:
URL: https://github.com/apache/arrow-rs/pull/1301#discussion_r805389418



##########
File path: arrow/src/json/reader.rs
##########
@@ -942,6 +943,32 @@ impl Decoder {
         ))
     }
 
+    #[allow(clippy::unnecessary_wraps)]
+    fn build_primitive_array_using_format_string<T>(
+        &self,
+        rows: &[Value],
+        col_name: &str,
+        format_string: &str,
+    ) -> Result<ArrayRef>
+    where
+        T: ArrowNumericType + Parser,
+        T::Native: num::NumCast,
+    {
+        Ok(Arc::new(
+            rows.iter()
+                .map(|row| {
+                    row.get(&col_name).and_then(|value| {
+                        if value.is_string() {

Review comment:
       Thanks ! I ended up using `and_then` to avoid calling `flatten`. it 
definitely looks cleaner

##########
File path: arrow/src/json/reader.rs
##########
@@ -1875,6 +1926,15 @@ mod tests {
             .unwrap();
         assert!(2.0 - bb.value(0) < f32::EPSILON);
         assert!(-3.5 - bb.value(1) < f32::EPSILON);
+        let ee = batch
+            .column(e.0)
+            .as_any()
+            .downcast_ref::<Date32Array>()
+            .unwrap();
+        dbg!(ee);
+        assert_eq!(1, ee.value(0));
+        assert_eq!(-1, ee.value(1));
+        assert!(!ee.is_valid(2));

Review comment:
       Sure, good point. Ended up moving to a different test altogether. 
   
   Not sure how to "check" a null value (index 2 is null as it does not fit the 
format), or did you mean index 1 ?




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