@@ -343,7 +343,6 @@ impl UnionFields {
343343 ///
344344 /// This function returns an error if:
345345 /// - Any type_id appears more than once (duplicate type ids)
346- /// - Any field appears more than once (duplicate fields)
347346 /// - The number of type_ids doesn't match the number of fields
348347 ///
349348 /// # Examples
@@ -362,7 +361,7 @@ impl UnionFields {
362361 /// );
363362 /// assert!(result.is_ok());
364363 ///
365- /// // This will fail due to duplicate type id
364+ /// // This will fail due to duplicate type ids
366365 /// let result = UnionFields::try_new(
367366 /// vec![1, 1],
368367 /// vec![
@@ -381,10 +380,7 @@ impl UnionFields {
381380 let mut type_ids_iter = type_ids. into_iter ( ) ;
382381 let mut fields_iter = fields. into_iter ( ) . map ( Into :: into) ;
383382
384- let fields_capacity = fields_iter. size_hint ( ) . 0 ;
385-
386383 let mut seen_type_ids = 0u128 ;
387- let mut seen_fields = HashSet :: with_capacity ( fields_capacity) ;
388384
389385 let mut out = Vec :: new ( ) ;
390386
@@ -409,13 +405,6 @@ impl UnionFields {
409405
410406 seen_type_ids |= mask;
411407
412- // check field id uniqueness
413- if !seen_fields. insert ( Arc :: clone ( & field) ) {
414- return Err ( ArrowError :: InvalidArgumentError ( format ! (
415- "duplicate field: {field}"
416- ) ) ) ;
417- }
418-
419408 out. push ( ( type_id, field) ) ;
420409 }
421410 ( None , Some ( _) ) => {
@@ -764,8 +753,7 @@ mod tests {
764753 fn test_union_fields_try_new_duplicate_field ( ) {
765754 let field = Field :: new ( "field" , DataType :: UInt8 , false ) ;
766755 let res = UnionFields :: try_new ( vec ! [ 1 , 2 ] , vec ! [ field. clone( ) , field] ) ;
767- assert ! ( res. is_err( ) ) ;
768- assert ! ( res. unwrap_err( ) . to_string( ) . contains( "duplicate field" ) ) ;
756+ assert ! ( res. is_ok( ) ) ;
769757 }
770758
771759 #[ test]
0 commit comments