kevinjqliu commented on code in PR #1246:
URL: https://github.com/apache/iceberg-python/pull/1246#discussion_r1818186598


##########
tests/catalog/test_base.py:
##########
@@ -766,3 +766,26 @@ def test_table_properties_raise_for_none_value(catalog: 
InMemoryCatalog) -> None
     with pytest.raises(ValidationError) as exc_info:
         _ = given_catalog_has_a_table(catalog, properties=property_with_none)
     assert "None type is not a supported value in properties: property_name" 
in str(exc_info.value)
+
+
+def test_abort_table_transaction_on_exception(catalog: InMemoryCatalog) -> 
None:
+    tbl = given_catalog_has_a_table(catalog)
+    # Populate some initial data
+    data = pa.Table.from_pylist(
+        [{"x": 1, "y": 2, "z": 3}, {"x": 4, "y": 5, "z": 6}],
+        schema=TEST_TABLE_SCHEMA.as_arrow(),
+    )
+    tbl.append(data)
+
+    # Data to overwrite
+    data = pa.Table.from_pylist(
+        [{"x": 7, "y": 8, "z": 9}, {"x": 7, "y": 8, "z": 9}, {"x": 7, "y": 8, 
"z": 9}],
+        schema=TEST_TABLE_SCHEMA.as_arrow(),
+    )
+
+    with pytest.raises(ValueError):
+        with tbl.transaction() as txn:
+            txn.overwrite(data)
+            raise ValueError
+

Review Comment:
   ```suggestion
       with pytest.raises(ValueError):
           with tbl.transaction() as txn:
               txn.overwrite(data)
               raise ValueError
               txn.overwrite(data)
   ```
   
   maybe another call after the exception



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