geruh commented on code in PR #3011:
URL: https://github.com/apache/iceberg-python/pull/3011#discussion_r2825382122


##########
pyiceberg/table/update/snapshot.py:
##########
@@ -344,14 +331,20 @@ def _commit(self) -> UpdatesAndRequirements:
     def snapshot_id(self) -> int:
         return self._snapshot_id
 
+    def schema(self, schema_id: int | None = None) -> Schema:

Review Comment:
   +1 on dropping. without that this would just become 
`self._transaction.table_metadata.schema()`. 



##########
pyiceberg/table/update/snapshot.py:
##########
@@ -366,6 +359,35 @@ def new_manifest_output(self) -> OutputFile:
     def fetch_manifest_entry(self, manifest: ManifestFile, discard_deleted: 
bool = True) -> list[ManifestEntry]:
         return manifest.fetch_manifest_entry(io=self._io, 
discard_deleted=discard_deleted)
 
+    def _build_partition_projection(self, spec_id: int) -> BooleanExpression:
+        project = inclusive_projection(self.schema(), self.spec(spec_id), 
self._case_sensitive)
+        return project(self._predicate)
+
+    @cached_property
+    def partition_filters(self) -> KeyDefaultDict[int, BooleanExpression]:
+        return KeyDefaultDict(self._build_partition_projection)
+
+    def _build_manifest_evaluator(self, spec_id: int) -> 
Callable[[ManifestFile], bool]:
+        return manifest_evaluator(self.spec(spec_id), self.schema(), 
self.partition_filters[spec_id], self._case_sensitive)
+
+    def delete_by_predicate(self, predicate: BooleanExpression, 
case_sensitive: bool = True) -> None:
+        self._predicate = Or(self._predicate, predicate)
+        self._case_sensitive = case_sensitive
+
+    def _build_delete_files_partition_predicate(self) -> None:
+        """Build BooleanExpression based on deleted data files partitions."""
+        partition_to_overwrite: dict[int, set[Record]] = {}
+        for data_file in self._deleted_data_files:
+            group = partition_to_overwrite.setdefault(data_file.spec_id, set())
+            group.add(data_file.partition)
+
+        for spec_id, data_files in partition_to_overwrite.items():

Review Comment:
   nit:  
   ```suggestion
           for spec_id, partition_records in partition_to_overwrite.items():
   ```



##########
pyiceberg/table/update/snapshot.py:
##########
@@ -51,9 +47,8 @@
     write_manifest,
     write_manifest_list,
 )
-from pyiceberg.partitioning import (
-    PartitionSpec,

Review Comment:
   This moved a bunch of the imports to multi line for some reason



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