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


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {
+                    if let Some(Value::String(mode)) = map.get("mode") {
+                        let union_mode = if mode == "SPARSE" {
+                            UnionMode::Sparse
+                        } else if mode == "DENSE" {
+                            UnionMode::Dense
+                        } else {
+                            return Err(ArrowError::ParseError(format!(
+                                "Unknown union mode {:?} for union",
+                                mode
+                            )));
+                        };
+                        if let Some(type_ids) = map.get("typeIds") {
+                            let type_ids = type_ids
+                                .as_array()
+                                .unwrap()
+                                .iter()
+                                .map(|t| t.as_i64().unwrap())
+                                .collect::<Vec<_>>();
+
+                            let default_fields = type_ids
+                                .iter()
+                                .map(|t| {
+                                    Field::new("", DataType::Boolean, 
true).with_metadata(

Review Comment:
   This is because, `type` (union, map, list, etc) is defined in "type" of the 
Json map, fields are defined in "children" of the map. We parse "type" to get 
the nested type and parse "children" to get actual fields after that. 



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