Fokko commented on code in PR #1661:
URL: https://github.com/apache/iceberg-python/pull/1661#discussion_r2093688570
##########
pyiceberg/table/update/snapshot.py:
##########
@@ -524,6 +531,153 @@ def _process_manifests(self, manifests:
List[ManifestFile]) -> List[ManifestFile
return
data_manifest_merge_manager.merge_manifests(unmerged_data_manifests) +
unmerged_deletes_manifests
+class _RewriteManifests(_SnapshotProducer["_RewriteManifests"]):
+ _table: Table
+ _spec_id: int
+ _target_size_bytes: int
+ _min_count_to_merge: int
+ _merge_enabled: bool
+ rewritten_manifests: List[ManifestFile] = []
+ added_manifests: List[ManifestFile] = []
+ kept_manifests: List[ManifestFile] = []
+
+ def __init__(
+ self,
+ table: Table,
+ transaction: Transaction,
+ io: FileIO,
+ spec_id: Optional[int] = None,
+ snapshot_properties: Dict[str, str] = EMPTY_DICT,
+ ):
+ from pyiceberg.table import TableProperties
+
+ super().__init__(Operation.REPLACE, transaction, io,
snapshot_properties=snapshot_properties)
+
+ snapshot = self._table.current_snapshot()
+ if self._spec_id and self._spec_id not in self._table.specs():
+ raise ValueError(f"Cannot find spec with id: {self._spec_id}")
+
+ if not snapshot:
+ raise ValueError("Cannot rewrite manifests without a current
snapshot")
+
+ self._target_size_bytes = property_as_int(
+ self._transaction.table_metadata.properties,
+ TableProperties.MANIFEST_TARGET_SIZE_BYTES,
+ TableProperties.MANIFEST_TARGET_SIZE_BYTES_DEFAULT,
+ ) # type: ignore
+ self._table = table
+ self._spec_id = spec_id or table.spec().spec_id
+
+ self._min_count_to_merge = property_as_int(
+ self._transaction.table_metadata.properties,
+ TableProperties.MANIFEST_MIN_MERGE_COUNT,
+ TableProperties.MANIFEST_MIN_MERGE_COUNT_DEFAULT,
+ ) # type: ignore
+ self._merge_enabled = property_as_bool(
+ self._transaction.table_metadata.properties,
+ TableProperties.MANIFEST_MERGE_ENABLED,
+ TableProperties.MANIFEST_MERGE_ENABLED_DEFAULT,
+ )
+
+ def _summary(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) ->
Summary:
+ from pyiceberg.table import TableProperties
+
+ ssc = SnapshotSummaryCollector()
+ partition_summary_limit = int(
+ self._transaction.table_metadata.properties.get(
+ TableProperties.WRITE_PARTITION_SUMMARY_LIMIT,
TableProperties.WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT
+ )
+ )
+ ssc.set_partition_summary_limit(partition_summary_limit)
Review Comment:
```suggestion
ssc = SnapshotSummaryCollector(int(
self._transaction.table_metadata.properties.get(
TableProperties.WRITE_PARTITION_SUMMARY_LIMIT,
TableProperties.WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT
)
))
```
--
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]