stevie9868 commented on code in PR #1246:
URL: https://github.com/apache/iceberg-python/pull/1246#discussion_r1819915765
##########
tests/integration/test_writes/test_writes.py:
##########
@@ -1448,3 +1448,27 @@ def
test_rewrite_manifest_after_partition_evolution(session_catalog: Catalog) ->
EqualTo("category", "A"),
),
)
+
+
[email protected]
[email protected]("format_version", [1, 2])
+def test_abort_table_transaction_on_exception(
+ spark: SparkSession, session_catalog: Catalog, arrow_table_with_null:
pa.Table, format_version: int
+) -> None:
+ identifier = "default.table_test_abort_table_transaction_on_exception"
+ tbl = _create_table(session_catalog, identifier,
properties={"format-version": format_version})
+
+ # Pre-populate some data
+ tbl.append(arrow_table_with_null)
+ table_size = len(arrow_table_with_null)
+ assert len(tbl.scan().to_pandas()) == table_size
+
+ # try to commit a transaction that raises exception at the middle
+ with pytest.raises(ValueError):
+ with tbl.transaction() as txn:
+ txn.append(arrow_table_with_null)
+ raise ValueError
+ txn.append(arrow_table_with_null) # type: ignore
Review Comment:
yeah, otherwise it will throw
`tests/integration/test_writes/test_writes.py:1470: error: Statement is
unreachable [unreachable]`
##########
tests/integration/test_writes/test_writes.py:
##########
@@ -1448,3 +1448,27 @@ def
test_rewrite_manifest_after_partition_evolution(session_catalog: Catalog) ->
EqualTo("category", "A"),
),
)
+
+
[email protected]
[email protected]("format_version", [1, 2])
+def test_abort_table_transaction_on_exception(
+ spark: SparkSession, session_catalog: Catalog, arrow_table_with_null:
pa.Table, format_version: int
+) -> None:
+ identifier = "default.table_test_abort_table_transaction_on_exception"
+ tbl = _create_table(session_catalog, identifier,
properties={"format-version": format_version})
+
+ # Pre-populate some data
+ tbl.append(arrow_table_with_null)
+ table_size = len(arrow_table_with_null)
+ assert len(tbl.scan().to_pandas()) == table_size
+
+ # try to commit a transaction that raises exception at the middle
+ with pytest.raises(ValueError):
+ with tbl.transaction() as txn:
+ txn.append(arrow_table_with_null)
+ raise ValueError
+ txn.append(arrow_table_with_null) # type: ignore
Review Comment:
yeah, otherwise make lint will throw
`tests/integration/test_writes/test_writes.py:1470: error: Statement is
unreachable [unreachable]`
--
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]