NoahKusaba opened a new pull request, #3303:
URL: https://github.com/apache/iceberg-rust/pull/3303

   ## Which issue does this PR close?
   
   - Closes #3297.
   
   ## What changes are included in this PR?
   
   `strip_metadata_from_schema` failed with `Field stack underflow in list` on 
any schema with a list or map column. `MetadataStripVisitor` pushes each 
field's name and nullability onto a stack in `before_field` and pops it when 
rebuilding the field. For list elements and map keys and values, the traversal 
calls `before_list_element`, `before_map_key` and `before_map_value` instead of 
`before_field`, so rebuilding them popped from an empty stack. The visitor now 
pushes in those three hooks too.
   
   While here:
   
   - The stack holds each field's name and nullability instead of a `Field` 
with a `DataType::Null` placeholder, and one `pop_field` helper rebuilds fields 
for `struct`, `list`, `map` and `primitive`.
   - The doc comment states two normalizations the function already made, which 
are now reachable for maps: a map's entries field is renamed to 
`DEFAULT_MAP_FIELD_NAME`, as `schema_to_arrow_schema` names it, and a 
dictionary-encoded field becomes its value type. Callers comparing stripped 
schemas rely on both. For example, 
[datafusion-iceberg](https://github.com/apache/datafusion-iceberg) compares an 
INSERT's input, whose map entries field DataFusion names `entries`, against the 
table's schema.
   
   ## Are these changes tested?
   
   Three unit tests in `arrow::schema`, each comparing the whole stripped 
schema with the expected one:
   
   - `test_strip_metadata_from_nested_schema`: lists, large and fixed-size 
lists, sorted and unsorted maps, and a list of structs holding a map of lists, 
with metadata on the schema and every field. Fails without the fix with the 
error from the issue.
   - `test_strip_metadata_renames_map_entries`
   - `test_strip_metadata_unwraps_dictionaries`
   
   ## AI Disclosure
   
   - Used Claude Code to review the fix, simplify the visitor, write the tests 
and draft this description. I reviewed the change.
   


-- 
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]

Reply via email to