RyanLin5967 opened a new issue, #4196:
URL: https://github.com/apache/iceberg-python/issues/4196

   ### Apache Iceberg version
   
   0.12.0 (latest release)
   
   ### Please describe the bug 🐞
   
   Currently, `dynamic_partition_overwrite` builds its delete filter from 
`find_field(source_id).name`, which is `x` for `s.x`, so it deletes the rows 
whose top-level `x` matches and keeps the old rows of the partition it 
replaces. Without a top-level column of that name it raises `ValueError`.
   
   ```python
   import tempfile
   import pyarrow as pa
   from pyiceberg.catalog.sql import SqlCatalog
   from pyiceberg.partitioning import PartitionField, PartitionSpec
   from pyiceberg.schema import Schema
   from pyiceberg.transforms import IdentityTransform
   from pyiceberg.types import LongType, NestedField, StructType
   
   cat = SqlCatalog("c", uri="sqlite:///:memory:", 
warehouse=f"file://{tempfile.mkdtemp()}")
   cat.create_namespace("ns")
   schema = Schema(NestedField(1, "x", LongType()), NestedField(2, "s", 
StructType(NestedField(3, "x", LongType()))))
   t = cat.create_table("ns.t", schema=schema, 
partition_spec=PartitionSpec(PartitionField(3, 1000, IdentityTransform(), 
"s_x")))
   df = lambda *rs: pa.Table.from_pylist([{"x": x, "s": {"x": sx}} for x, sx in 
rs], schema=schema.as_arrow())
   t.append(df((1, 5), (5, 1)))
   
   t.dynamic_partition_overwrite(df((9, 5)))
   print(sorted((r["x"], r["s"]["x"]) for r in t.scan().to_arrow().to_pylist()))
   # [(1, 5), (9, 5)], should be [(5, 1), (9, 5)]
   # rows are (x, s.x): partition s.x = 1 lost its row and s.x = 5 kept its old 
one
   ```
   
   `_determine_partitions` uses `find_column_name` for the same field since 
#2204.
   
   tested on pyiceberg 0.12.0 and main
   
   ### Willingness to contribute
   
   - [ ] I can contribute a fix for this bug independently
   - [ ] I would be willing to contribute a fix for this bug with guidance from 
the Iceberg community
   - [ ] I cannot contribute a fix for this bug at this time


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