ASRodrigo1 commented on code in PR #4303:
URL: https://github.com/apache/iceberg-python/pull/4303#discussion_r4543931239
##########
pyiceberg/table/update/__init__.py:
##########
@@ -763,7 +763,16 @@ def update_table_metadata(
if enforce_validation:
return TableMetadataUtil.parse_obj(new_metadata.model_dump())
else:
- return new_metadata.model_copy(deep=True)
+ return _copy_containers(new_metadata)
+
+
+def _copy_containers(metadata: TableMetadata) -> TableMetadata:
+ """Copy the list and dict fields of the metadata and share the frozen
models they hold.
+
+ The frozen config cannot prevent a list append or a dict assignment on a
field, so copying the
+ containers keeps the base metadata isolated without deep-copying the whole
table history.
+ """
+ return metadata.model_copy(update={name: value.copy() for name, value in
metadata if isinstance(value, (list, dict))})
Review Comment:
Thanks, applied in d9d6af80. The suggested line uses `metadata`, but the
variable in scope there is `new_metadata`, so I renamed it. `ruff format` split
the line in two to fit the line length.
--
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]