alamb commented on code in PR #8529:
URL: https://github.com/apache/arrow-rs/pull/8529#discussion_r2395881543


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -248,4 +265,22 @@ mod tests {
             "FixedSizeList(4 x nullable Int32, metadata: {\"key2\": 
\"value2\"})";
         assert_eq!(fixed_size_metadata_string, expected_metadata_string);
     }
+
+    #[test]
+    fn test_display_union() {
+        let fields = vec![
+            Field::new("a", DataType::Int32, false),
+            Field::new("b", DataType::Utf8, true),
+        ];
+        let type_ids = vec![0, 1];
+        let union_fields = type_ids
+            .into_iter()
+            .zip(fields.into_iter().map(Arc::new))
+            .collect();
+
+        let union_data_type = DataType::Union(union_fields, 
crate::UnionMode::Sparse);
+        let union_data_type_string = union_data_type.to_string();
+        let expected_string = "Union(Sparse, 0: Int32, 1: nullable Utf8)";

Review Comment:
   Can you also please add a test for when the field has metadata? 



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -132,7 +132,24 @@ impl fmt::Display for DataType {
                 Ok(())
             }
             Self::Union(union_fields, union_mode) => {
-                write!(f, "Union({union_fields:?}, {union_mode:?})")
+                write!(f, "Union({union_mode:?}, ")?;

Review Comment:
   the PR description says "Struct" but this PR appears to improve the 
formatting for "Union"



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