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


##########
parquet/src/arrow/array_reader/map_array.rs:
##########
@@ -43,15 +35,43 @@ impl MapArrayReader {
         data_type: ArrowType,
         def_level: i16,
         rep_level: i16,
+        nullable: bool,
     ) -> Self {
-        Self {
-            key_reader,
-            value_reader,
-            data_type,
-            // These are the wrong way round 
https://github.com/apache/arrow-rs/issues/1699
-            map_def_level: rep_level,
-            map_rep_level: def_level,
-        }
+        let struct_def_level = match nullable {
+            true => def_level + 2,
+            false => def_level + 1,
+        };
+        let struct_rep_level = rep_level + 1;
+
+        let element = match &data_type {
+            ArrowType::Map(element, _) => match element.data_type() {
+                ArrowType::Struct(fields) if fields.len() == 2 => {
+                    // The inner map field must always non-nullable (#1697)
+                    assert!(!element.is_nullable(), "map struct cannot be 
nullable");
+                    element
+                }
+                _ => unreachable!("expected struct with two fields"),

Review Comment:
   This isn't a public API so I could change it, but that also makes me less 
inclined to do so. It is a bug in the builder if you run into this



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