blackmwk commented on code in PR #2307:
URL: https://github.com/apache/iceberg-rust/pull/2307#discussion_r3026144097
##########
crates/iceberg/src/arrow/reader.rs:
##########
@@ -1111,14 +1111,24 @@ fn build_field_id_map(parquet_schema:
&SchemaDescriptor) -> Result<Option<HashMa
}
/// Build a fallback field ID map for Parquet files without embedded field IDs.
-/// Position-based (1, 2, 3, ...) for compatibility with iceberg-java
migrations.
+///
+/// Must use top-level field positions (not leaf column positions) to stay
consistent
+/// with `add_fallback_field_ids_to_arrow_schema`, which assigns ordinal IDs to
+/// top-level Arrow fields. Using leaf positions instead would produce wrong
indices
+/// when nested types (struct/list/map) expand into multiple leaf columns.
+///
+/// Matches iceberg-java's ParquetSchemaUtil.addFallbackIds().
fn build_fallback_field_id_map(parquet_schema: &SchemaDescriptor) ->
HashMap<i32, usize> {
Review Comment:
Got it, thanks for the explaination! Hopefully we could refactor it someday
to make the logic more similar to java.
--
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]