tustvold commented on code in PR #5646:
URL: https://github.com/apache/arrow-rs/pull/5646#discussion_r1565884800


##########
arrow-json/src/writer.rs:
##########
@@ -2215,4 +2216,86 @@ mod tests {
             );
         }
     }
+
+    #[test]
+    fn test_writer_fixed_size_list() {
+        let size = 3;
+        let field = FieldRef::new(Field::new("item", DataType::Int32, true));
+        let schema = SchemaRef::new(Schema::new(vec![Field::new(
+            "list",
+            DataType::FixedSizeList(field, size),
+            true,
+        )]));
+
+        let values_builder = Int32Builder::new();
+        let mut list_builder = FixedSizeListBuilder::new(values_builder, size);
+        let lists = [
+            Some([Some(1), Some(2), None]),
+            Some([Some(3), None, Some(4)]),
+            Some([None, Some(5), Some(6)]),
+            None,
+        ];
+        for list in lists {
+            match list {
+                Some(l) => {
+                    for value in l {
+                        match value {
+                            Some(v) => list_builder.values().append_value(v),
+                            None => list_builder.values().append_null(),
+                        }
+                    }
+                    list_builder.append(true);
+                }
+                None => {
+                    for _ in 0..size {
+                        list_builder.values().append_null();
+                    }
+                    list_builder.append(false);
+                }
+            }
+        }
+        let array = Arc::new(list_builder.finish()) as ArrayRef;
+        let batch = RecordBatch::try_new(schema, vec![array]).unwrap();
+
+        //encode and check JSON with explicit nulls:

Review Comment:
   :heart: 



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