fvaleye commented on code in PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#discussion_r2246062312
##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -459,14 +459,17 @@ impl PartnerAccessor<ArrayRef> for ArrowArrayAccessor {
.fields()
.iter()
.position(|arrow_field| {
+ // match by ID if available, otherwise try matching by name
get_field_id(arrow_field)
- .map(|id| id == field.id)
- .unwrap_or(false)
+ .map_or(arrow_field.name() == &field.name, |id| id ==
field.id)
})
.ok_or_else(|| {
Error::new(
ErrorKind::DataInvalid,
- format!("Field id {} not found in struct array", field.id),
+ format!(
+ "Field with id={} or name={} not found in struct
array",
+ field.id, field.name
+ ),
Review Comment:
**nitpick:** It might be helpful to log the available field names, since
neither `field.id` nor `field.name` matched.
```suggestion
format!(
"Field with id={} or name={} not found in struct
array. Available fields: [{}]",
field.id,
field.name,
struct_array
.fields()
.iter()
.map(|f| f.name().as_str())
.collect::<Vec<_>>()
.join(", ")
),
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]