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

   ### Apache Iceberg version
   
   0.12.0 (latest release)
   
   ### Please describe the bug 🐞
   
   Currently, `Transaction.dynamic_partition_overwrite` partitions its files 
with the committed spec but builds its delete filter with the transaction's, so 
the new row's `a = 1` is read as `b = 1` and the row with `b = 1` is deleted. 
Committing `update_spec` first gives the right rows.
   
   ```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
   
   cat = SqlCatalog("c", uri="sqlite:///:memory:", 
warehouse=f"file://{tempfile.mkdtemp()}")
   cat.create_namespace("ns")
   schema = Schema(NestedField(1, "a", LongType()), NestedField(2, "b", 
LongType()))
   t = cat.create_table("ns.t", schema=schema, 
partition_spec=PartitionSpec(PartitionField(1, 1000, IdentityTransform(), "a")))
   df = lambda *rs: pa.Table.from_pylist([{"a": a, "b": b} for a, b in rs], 
schema=schema.as_arrow())
   t.append(df((1, 9), (2, 1)))
   
   with t.transaction() as tx:
       with tx.update_spec() as u:
           u.remove_field("a")
           u.add_identity("b")
       tx.dynamic_partition_overwrite(df((1, 2)))
   
   rows = lambda f="True": sorted((r["a"], r["b"]) for r in 
t.scan(row_filter=f).to_arrow().to_pylist())
   print(rows())
   # [(1, 2), (1, 9)], should be [(1, 2), (1, 9), (2, 1)]
   print(rows("b == 2"))
   # [], should be [(1, 2)]
   # the new file is recorded under b = 1, its a value
   ```
   
   After an in-transaction `add_column` it raises `ValueError: Could not find 
field with name: w`.
   
   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