@@ -459,15 +459,9 @@ impl PartnerAccessor<ArrayRef> for ArrowArrayAccessor {
459
459
. fields ( )
460
460
. iter ( )
461
461
. position ( |arrow_field| {
462
+ // match by ID if available, otherwise try matching by name
462
463
get_field_id ( arrow_field)
463
- . map ( |id| id == field. id )
464
- . unwrap_or ( false )
465
- } )
466
- . or_else ( || {
467
- struct_array
468
- . fields ( )
469
- . iter ( )
470
- . position ( |arrow_field| arrow_field. name ( ) . clone ( ) == field. name )
464
+ . map_or ( arrow_field. name ( ) == & field. name , |id| id == field. id )
471
465
} )
472
466
. ok_or_else ( || {
473
467
Error :: new (
@@ -922,9 +916,9 @@ mod test {
922
916
Arc :: new( int32_array) as ArrayRef ,
923
917
) ,
924
918
(
925
- // Field with wrong field ID metadata - should fallback to name matching
919
+ // Field with the correct field ID metadata
926
920
Arc :: new( Field :: new( "field_b" , DataType :: Utf8 , true ) . with_metadata(
927
- HashMap :: from( [ ( PARQUET_FIELD_ID_META_KEY . to_string( ) , "999 " . to_string( ) ) ] ) ,
921
+ HashMap :: from( [ ( PARQUET_FIELD_ID_META_KEY . to_string( ) , "2 " . to_string( ) ) ] ) ,
928
922
) ) ,
929
923
Arc :: new( string_array) as ArrayRef ,
930
924
) ,
@@ -938,7 +932,7 @@ mod test {
938
932
Type :: Primitive ( PrimitiveType :: Int ) ,
939
933
) ) ,
940
934
Arc :: new( NestedField :: optional(
941
- 2 , // Different ID than what's in Arrow metadata (999)
935
+ 2 , // Same ID
942
936
"field_b" , // Same name as Arrow field
943
937
Type :: Primitive ( PrimitiveType :: String ) ,
944
938
) ) ,
0 commit comments