malon64 commented on code in PR #4496:
URL: https://github.com/apache/iceberg-python/pull/4496#discussion_r4728520626
##########
pyiceberg/table/__init__.py:
##########
@@ -1364,6 +1374,128 @@ def commit_transaction(self) -> Table:
return self._table
+class ReplaceTableTransaction(Transaction):
+ """A transaction that atomically replaces the definition and data of an
existing table.
+
+ Mirrors Java's TableMetadata.buildReplacement: the UUID, snapshots and
history are kept, the main
+ branch is removed, field IDs are reused by name, and properties are merged
into the existing ones.
+ """
+
+ def __init__(
+ self,
+ table: Table,
+ schema: Schema,
+ location: str | None = None,
+ partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
+ sort_order: SortOrder = UNSORTED_SORT_ORDER,
+ properties: Properties = EMPTY_DICT,
+ ):
+ super().__init__(table, autocommit=False)
+ base = table.metadata
+ properties = dict(properties)
+ format_version = int(properties.pop(TableProperties.FORMAT_VERSION,
base.format_version))
Review Comment:
Added the upper bound check and
_check_properties_format_version_compatibility, both up front instead of at
commit. Test added.
--
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]