Closed sungwy closed 2 months ago
Thanks for tracking this @syun64, can I pick this one up? :)
Yes of course!
Just a note that's hopefully helpful: while working on covering more cases for #921 , I realized this may require a bit more work than I originally thought. We currently rely on a flat name mapping in many places throughout the repository, including when we aggregate stats from the parquet files:
So I think we will need to build a tree representation of the Name to ID mapping for a given pyarrow schema as well.
Apache Iceberg version
None
Please describe the bug 🐞
According to the Iceberg documentation on Column Projection:
The current implementation of NameMapping flattens the name by joining the parent child relationships with a
.
. This causes name collisions issues with fields that should not collide with each other.For example, this flat map causes
a.b
field to collide with childb
field of fielda
.We should update
_field_by_name()
andfind()
methods of NameMapping to use a tree structure instead of a flat dict, and traverse the tree in order to retrieveMappedField
of the provided name.https://github.com/apache/iceberg-python/blob/e27cd9095503cfe9fa7e0a806ba25d42920c68c5/pyiceberg/table/name_mapping.py#L73-L82