@@ -117,21 +117,14 @@ impl<K: ArrayBuilder, V: ArrayBuilder> MapBuilder<K, V> {
117
117
///
118
118
/// By default, a nullable field is created with the name `keys`
119
119
///
120
- /// Returns an error if the given field is nullable.
121
- ///
122
120
/// Note: [`Self::finish`] and [`Self::finish_cloned`] will panic if the
123
- /// field's data type does not match that of `K`
124
- pub fn with_keys_field ( self , field : impl Into < FieldRef > ) -> Result < Self , ArrowError > {
125
- let field: FieldRef = field. into ( ) ;
126
- if field. is_nullable ( ) {
127
- return Err ( ArrowError :: InvalidArgumentError ( format ! (
128
- "Key field must not be nullable: {field:?}"
129
- ) ) ) ;
130
- }
131
- Ok ( Self {
132
- key_field : Some ( field) ,
121
+ /// field's data type does not match that of `K`, or if the keys array
122
+ /// contains any null values.
123
+ pub fn with_keys_field ( self , field : impl Into < FieldRef > ) -> Self {
124
+ Self {
125
+ key_field : Some ( field. into ( ) ) ,
133
126
..self
134
- } )
127
+ }
135
128
}
136
129
137
130
/// Override the field passed to [`MapBuilder::new`]
@@ -412,8 +405,7 @@ mod tests {
412
405
Field :: new ( "keys" , DataType :: Int32 , false ) . with_metadata ( key_metadata. clone ( ) ) ,
413
406
) ;
414
407
let mut builder = MapBuilder :: new ( None , Int32Builder :: new ( ) , Int32Builder :: new ( ) )
415
- . with_keys_field ( key_field. clone ( ) )
416
- . unwrap ( ) ;
408
+ . with_keys_field ( key_field. clone ( ) ) ;
417
409
builder. keys ( ) . append_value ( 1 ) ;
418
410
builder. values ( ) . append_value ( 2 ) ;
419
411
builder. append ( true ) . unwrap ( ) ;
@@ -441,12 +433,4 @@ mod tests {
441
433
)
442
434
) ;
443
435
}
444
-
445
- #[ test]
446
- fn test_with_nullable_keys_field ( ) {
447
- let result = MapBuilder :: new ( None , Int32Builder :: new ( ) , Int32Builder :: new ( ) )
448
- . with_keys_field ( Arc :: new ( Field :: new ( "keys" , DataType :: Int32 , true ) ) ) ;
449
-
450
- assert ! ( result. is_err( ) ) ;
451
- }
452
436
}
0 commit comments