rshkv commented on code in PR #7101:
URL: https://github.com/apache/arrow-rs/pull/7101#discussion_r1948179727


##########
arrow-array/src/builder/map_builder.rs:
##########
@@ -107,13 +108,32 @@ impl<K: ArrayBuilder, V: ArrayBuilder> MapBuilder<K, V> {
             field_names: field_names.unwrap_or_default(),
             key_builder,
             value_builder,
+            key_field: None,
             value_field: None,
         }
     }
 
     /// Override the field passed to [`MapBuilder::new`]
     ///
-    /// By default a nullable field is created with the name `values`
+    /// By default, a nullable field is created with the name `keys`
+    ///
+    /// This function panics if the given field is nullable as map keys are not
+    /// allowed to be null
+    ///
+    /// Note: [`Self::finish`] and [`Self::finish_cloned`] will panic if the
+    /// field's data type does not match that of `K`
+    pub fn with_keys_field(self, field: impl Into<FieldRef>) -> Self {
+        let field: FieldRef = field.into();
+        assert!(!field.is_nullable(), "Key field must not be nullable");

Review Comment:
   Yeah, I've removed checking for nullability of the key field. I didn't love 
that `MapBuilder::with_keys_field` returns a `Result` while 
`MapBuilder::with_values_field` or `GenericListBuilder::with_field` do not. We 
still ensure that we protect against nulls with the existing assertion in 
`finish`.
   
   Happy to go back to returning `Result`. Not feeling strongly about 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