alamb commented on a change in pull request #16:
URL: https://github.com/apache/arrow-rs/pull/16#discussion_r617547804



##########
File path: arrow/src/json/writer.rs
##########
@@ -709,6 +715,56 @@ mod tests {
         );
     }
 
+    #[test]
+    fn write_dictionary() {
+        let schema = Schema::new(vec![
+            Field::new(
+                "c1",
+                DataType::Dictionary(Box::new(DataType::Int32), 
Box::new(DataType::Utf8)),
+                true,
+            ),
+            Field::new(
+                "c2",
+                DataType::Dictionary(Box::new(DataType::Int8), 
Box::new(DataType::Utf8)),
+                true,
+            ),
+        ]);
+
+        let a: DictionaryArray<Int32Type> = vec![
+            Some("cupcakes"),
+            Some("foo"),
+            Some("foo"),
+            None,
+            Some("cupcakes"),
+        ]
+        .into_iter()
+        .collect();
+        let b: DictionaryArray<Int8Type> =
+            vec![Some("sdsd"), Some("sdsd"), None, Some("sd"), Some("sdsd")]
+                .into_iter()
+                .collect();
+
+        let batch =
+            RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a), 
Arc::new(b)])
+                .unwrap();
+
+        let mut buf = Vec::new();
+        {
+            let mut writer = LineDelimitedWriter::new(&mut buf);
+            writer.write_batches(&[batch]).unwrap();
+        }
+
+        assert_eq!(
+            String::from_utf8(buf).unwrap(),
+            r#"{"c1":"cupcakes","c2":"sdsd"}

Review comment:
       🧁 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to