zerafachris opened a new pull request, #4509:
URL: https://github.com/apache/iceberg-python/pull/4509

   <!--
   Thanks for opening a pull request!
   -->
   
   Closes #4486
   
   # Rationale for this change
   
   When a partition field is dropped from a v1 table (or a v2 table upgraded 
from v1), `PartitionSpec.fields` retains a `VoidTransform` field.
   `Transaction.dynamic_partition_overwrite` iterated over all `spec.fields`, 
which caused it to:
   1. Raise `ValueError: For now dynamic overwrite does not support a table 
with non-identity-transform field ...` whenever any `VoidTransform` field was 
present.
   2. Treat a partition spec whose fields are all `VoidTransform` as 
partitioned rather than unpartitioned.
   3. Fail to project `data_file.partition` records to only the active non-void 
positions when building the delete filter (which matters especially when a 
`VoidTransform` field precedes an active `IdentityTransform` field in 
`spec.fields`, since `data_file.partition` is positionally indexed by 
`spec.fields`).
   
   This change filters `spec.fields` to active non-void fields `(pos, field)`, 
raises the unpartitioned `ValueError` if none remain, validates 
`IdentityTransform` only on active fields, and projects 
`Record(*(data_file.partition[pos] for pos, _ in non_void_fields))` for the 
partition overwrite filter.
   
   Note: This addresses a distinct failure mode in 
`Transaction.dynamic_partition_overwrite` from #4204 (which resolves nested 
column paths in `_build_partition_predicate`).
   
   ## Are these changes tested?
   
   Yes. Added unit tests in `tests/table/test_init.py`:
   - `test_dynamic_partition_overwrite_with_void_partition_field` (both v1 and 
upgraded-to-v2 tables)
   - `test_dynamic_partition_overwrite_with_leading_void_partition_field` 
(verifies positional projection when a `VoidTransform` precedes an active 
partition field)
   - `test_dynamic_partition_overwrite_all_void_partition_fields_raises`
   
   Verified locally:
   - `pytest tests/table/ tests/catalog/test_catalog_behaviors.py -m unit`: 
1037 passed
   - `pytest tests/ -m unit --ignore=tests/integration 
--ignore=tests/avro/test_decoder.py --ignore=tests/avro/test_reader.py 
--ignore=tests/avro/test_resolver.py --ignore=tests/catalog/test_hive.py`: 4721 
passed, 6 skipped, 129 deselected
   - `ruff check` and `ruff format --check` on modified files: passed
   
   ## Are there any user-facing changes?
   
   No.
   


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