tustvold commented on code in PR #7101:
URL: https://github.com/apache/arrow-rs/pull/7101#discussion_r1951722391
##########
arrow-array/src/builder/map_builder.rs:
##########
@@ -107,13 +108,31 @@ 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`
+ ///
+ /// Returns an error if the given field is nullable.
+ ///
+ /// 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(), "Keys field must not be nullable");
Review Comment:
We could also move this check into finish, but I don't think it really
matters
##########
arrow-array/src/builder/map_builder.rs:
##########
@@ -107,13 +108,31 @@ 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`
+ ///
+ /// Returns an error if the given field is nullable.
Review Comment:
I think this needs to be updated
--
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]