HonahX commented on code in PR #182: URL: https://github.com/apache/iceberg-python/pull/182#discussion_r1414899521
########## pyiceberg/table/__init__.py: ########## @@ -533,6 +535,8 @@ def update_table_metadata(base_metadata: TableMetadata, updates: Tuple[TableUpda for update in updates: new_metadata = _apply_table_update(update, new_metadata, context) + # Rebuild metadata to trigger validation + new_metadata = TableMetadataUtil.parse_obj(copy(new_metadata.model_dump())) Review Comment: Since `model_copy` performs a shallow copy by default, I believe we need to execute a deep copy before returning the final `new_metadata`. Otherwise, `base_metadata` might be inadvertently altered due to any improper updates applied to `new_metadata` subsequently. Furthermore, as indicated by https://github.com/pydantic/pydantic/issues/418 and by some local tests, `model_copy(update=)` does not validate the contents of update. I think it might be good to reconstruct the metadata at this point to initiate the validation process. (Alternatively, we could perform a deep copy here and incorporate the validation into our unit tests. Open to discussion on this approach.) -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org