Skip to content

Commit d50255c

Browse files
committed
lol
1 parent e8713c0 commit d50255c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

crates/iceberg/src/arrow/value.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,9 @@ impl PartnerAccessor<ArrayRef> for ArrowArrayAccessor {
459459
.fields()
460460
.iter()
461461
.position(|arrow_field| {
462+
// match by ID if available, otherwise try matching by name
462463
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)
471465
})
472466
.ok_or_else(|| {
473467
Error::new(
@@ -922,9 +916,9 @@ mod test {
922916
Arc::new(int32_array) as ArrayRef,
923917
),
924918
(
925-
// Field with wrong field ID metadata - should fallback to name matching
919+
// Field with the correct field ID metadata
926920
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())]),
928922
)),
929923
Arc::new(string_array) as ArrayRef,
930924
),
@@ -938,7 +932,7 @@ mod test {
938932
Type::Primitive(PrimitiveType::Int),
939933
)),
940934
Arc::new(NestedField::optional(
941-
2, // Different ID than what's in Arrow metadata (999)
935+
2, // Same ID
942936
"field_b", // Same name as Arrow field
943937
Type::Primitive(PrimitiveType::String),
944938
)),

0 commit comments

Comments
 (0)