Skip to content

Commit 915b85f

Browse files
committed
Clear updates/requirements after commit
Resolves apache#1946
1 parent eb8756a commit 915b85f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pyiceberg/table/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,15 @@ def commit_transaction(self) -> Table:
773773
updates=self._updates,
774774
requirements=self._requirements,
775775
)
776+
self._updates = ()
777+
self._requirements = ()
776778
return self._table
777779
else:
778780
return self._table
779781

780782

781783
class CreateTableTransaction(Transaction):
782-
"""A transaction that involves the creation of a a new table."""
784+
"""A transaction that involves the creation of a new table."""
783785

784786
def _initial_changes(self, table_metadata: TableMetadata) -> None:
785787
"""Set the initial changes that can reconstruct the initial table metadata when creating the CreateTableTransaction."""

tests/integration/test_writes/test_writes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,3 +1684,13 @@ def test_write_optional_list(session_catalog: Catalog) -> None:
16841684
session_catalog.load_table(identifier).append(df_2)
16851685

16861686
assert len(session_catalog.load_table(identifier).scan().to_arrow()) == 4
1687+
1688+
1689+
@pytest.mark.integration
1690+
def test_double_commit_transaction(spark: SparkSession, session_catalog: Catalog, arrow_table_with_null: pa.Table) -> None:
1691+
identifier = "default.arrow_data_files"
1692+
tbl = _create_table(session_catalog, identifier, {"format-version": "1"}, [])
1693+
1694+
with tbl.transaction() as tx:
1695+
tx.append(arrow_table_with_null)
1696+
tx.commit_transaction()

0 commit comments

Comments
 (0)