harshilv17 opened a new pull request, #4508: URL: https://github.com/apache/iceberg-python/pull/4508
Closes #4507 # Rationale for this change On a commit retry, `_validate_no_new_delete_files` is called with `partition_set=None`, and `_added_delete_files` can only rule out a delete file by its column stats. Position deletes and deletion vectors have no stats on data columns, so a delete file committed concurrently in any partition fails a partition-filtered `delete()` or `overwrite()`. This shows up on tables shared with Spark or Flink merge-on-read writers. It was raised in the #3320 review and deferred with a code comment. Java scopes this by partition: `DeleteFileIndex.Builder` projects the data filter onto each spec with `Projections.inclusive(spec, caseSensitive)` and filters delete manifest entries by partition. This change does the same in `_added_delete_files`: when a `data_filter` is given, it builds a per-spec evaluator from `inclusive_projection` + `expression_evaluator` (as `DataScan._build_partition_evaluator` does) and skips delete files whose partition can't match. A filter on non-partition columns projects to `AlwaysTrue`, so those delete files still count as conflicts. The comment deferring this in `snapshot.py` is removed. ## Are these changes tested? Yes. `test_partition_filtered_write_validates_concurrent_position_delete_by_partition` in `tests/table/test_commit_retry.py` commits a concurrent position delete (with the existing `commit_partition_position_delete` helper) in the written partition and in another one, for both `delete` and `overwrite`, on each catalog fixture. On main the other-partition cases fail with `ValidationException: Found new conflicting delete files`; with this change they succeed, and the same-partition cases still conflict. `test_added_delete_files_case_insensitive_filter` used a mock delete file with `partition=None` on a table partitioned by `x`, which a real manifest can't contain; it now has `partition=Record(1)`. `tests/table` passes, and ruff and mypy are clean. ## Are there any user-facing changes? Yes: a `delete()` or `overwrite()` filtered to some partitions no longer fails its commit retry because another writer committed a delete file in an unrelated partition. -- 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]
