Fokko commented on code in PR #6323:
URL: https://github.com/apache/iceberg/pull/6323#discussion_r1220367976


##########
python/pyiceberg/table/__init__.py:
##########
@@ -69,21 +72,313 @@
     import ray
     from duckdb import DuckDBPyConnection
 
+    from pyiceberg.catalog import Catalog
 
 ALWAYS_TRUE = AlwaysTrue()
 
 
+class TableUpdates:
+    _table: Table
+    _updates: Tuple[TableUpdate, ...]
+    _requirements: Tuple[TableRequirement, ...]
+
+    def __init__(
+        self,
+        table: Table,
+        actions: Optional[Tuple[TableUpdate, ...]] = None,
+        requirements: Optional[Tuple[TableRequirement, ...]] = None,
+    ):
+        self._table = table
+        self._updates = actions or ()
+        self._requirements = requirements or ()
+
+    def _append_updates(self, *new_updates: TableUpdate) -> TableUpdates:
+        """Appends updates to the set of staged updates
+
+        Args:
+            *new_updates: Any new updates
+
+        Raises:
+            ValueError: When the type of update is not unique.
+
+        Returns:
+            A new AlterTable object with the new updates appended
+        """
+        for new_update in new_updates:
+            type_new_update = type(new_update)
+            if any(type(update) == type_new_update for update in 
self._updates):
+                raise ValueError(f"Updates in a single commit need to be 
unique, duplicate: {type_new_update}")

Review Comment:
   Updated it to:
   ```python
   with table.transaction() as transaction:
       transaction.set_properties(abc="def")
   
   assert table.properties == {"abc": "def"}
   
   with table.transaction() as transaction:
       transaction.remove_properties("abc")
   
   assert table.properties == {}
   ```
   
   Or without a context manager:
   ```python
   table = table.transaction().set_properties(abc="def").commit_transaction()
   
   assert table.properties == {"abc": "def"}
   
   table = table.transaction().remove_properties("abc").commit_transaction()
   
   assert table.properties == {}
   ```



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

Reply via email to