smaheshwar-pltr commented on code in PR #1903:
URL: https://github.com/apache/iceberg-python/pull/1903#discussion_r2038636230


##########
pyiceberg/table/__init__.py:
##########
@@ -255,12 +254,15 @@ def __init__(self, table: Table, autocommit: bool = 
False):
             table: The table that will be altered.
             autocommit: Option to automatically commit the changes when they 
are staged.
         """
-        self.table_metadata = table.metadata
         self._table = table
         self._autocommit = autocommit
         self._updates = ()
         self._requirements = ()
 
+    @property
+    def table_metadata(self) -> TableMetadata:
+        return update_table_metadata(self._table.metadata, self._updates)

Review Comment:
   Curious about performance implications of this change for when metadata gets 
large - with it, and assuming no `autocommit`, it seems that that each use of 
`table_metadata` will start with the original metadata of the *table*, not the 
current one of the transaction (which is what was done before), and apply *all* 
updates to it, not just the most recent one, copying it every time via 
`model_copy`?
   
   I think what was here before, `self.table_metadata = 
update_table_metadata(self.table_metadata, updates)`, only applies just the 
necessary updates within `_apply`, and stores results in a field along the way 
to continually update just the current transactional metadata. Because of that, 
continually using `table_metadata`, either [via PyIceberg 
code](https://github.com/apache/iceberg-python/blob/15887011cb6bae9a4408eedc2824133efa3e1599/pyiceberg/table/__init__.py#L298-L320)
 or user code seemed cheap before but maybe no longer.



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

Reply via email to