Skip to content

Commit 4f6faa9

Browse files
author
Yingjian Wu
committed
address comments
1 parent f7a7a87 commit 4f6faa9

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

tests/catalog/test_base.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -766,26 +766,3 @@ def test_table_properties_raise_for_none_value(catalog: InMemoryCatalog) -> None
766766
with pytest.raises(ValidationError) as exc_info:
767767
_ = given_catalog_has_a_table(catalog, properties=property_with_none)
768768
assert "None type is not a supported value in properties: property_name" in str(exc_info.value)
769-
770-
771-
def test_abort_table_transaction_on_exception(catalog: InMemoryCatalog) -> None:
772-
tbl = given_catalog_has_a_table(catalog)
773-
# Populate some initial data
774-
data = pa.Table.from_pylist(
775-
[{"x": 1, "y": 2, "z": 3}, {"x": 4, "y": 5, "z": 6}],
776-
schema=TEST_TABLE_SCHEMA.as_arrow(),
777-
)
778-
tbl.append(data)
779-
780-
# Data to overwrite
781-
data = pa.Table.from_pylist(
782-
[{"x": 7, "y": 8, "z": 9}, {"x": 7, "y": 8, "z": 9}, {"x": 7, "y": 8, "z": 9}],
783-
schema=TEST_TABLE_SCHEMA.as_arrow(),
784-
)
785-
786-
with pytest.raises(ValueError):
787-
with tbl.transaction() as txn:
788-
txn.overwrite(data)
789-
raise ValueError
790-
791-
assert len(tbl.scan().to_pandas()) == 2 # type: ignore

tests/integration/test_writes/test_writes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,3 +1448,26 @@ def test_rewrite_manifest_after_partition_evolution(session_catalog: Catalog) ->
14481448
EqualTo("category", "A"),
14491449
),
14501450
)
1451+
1452+
1453+
@pytest.mark.integration
1454+
@pytest.mark.parametrize("format_version", [1, 2])
1455+
def test_abort_table_transaction_on_exception(
1456+
spark: SparkSession, session_catalog: Catalog, arrow_table_with_null: pa.Table, format_version: int
1457+
) -> None:
1458+
identifier = "default.table_test_abort_table_transaction_on_exception"
1459+
tbl = _create_table(session_catalog, identifier, properties={"format-version": format_version})
1460+
1461+
# Pre-populate some data
1462+
tbl.append(arrow_table_with_null)
1463+
assert len(tbl.scan().to_pandas()) == 3
1464+
1465+
# try to commit a transaction that raises exception at the middle
1466+
with pytest.raises(ValueError):
1467+
with tbl.transaction() as txn:
1468+
txn.append(arrow_table_with_null)
1469+
raise ValueError
1470+
txn.append(arrow_table_with_null) # type: ignore
1471+
1472+
# Validate the transaction is aborted
1473+
assert len(tbl.scan().to_pandas()) == 3 # type: ignore

0 commit comments

Comments
 (0)