Skip to content

Commit

Permalink
Add small test on duplicate changes (apache#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko authored Jan 18, 2024
1 parent 8b660f8 commit 8614ba0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/catalog/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pyiceberg.catalog import Identifier
from pyiceberg.catalog.sql import SqlCatalog
from pyiceberg.exceptions import (
CommitFailedException,
NamespaceAlreadyExistsError,
NamespaceNotEmptyError,
NoSuchNamespaceError,
Expand Down Expand Up @@ -719,3 +720,26 @@ def test_commit_table(catalog: SqlCatalog, table_schema_nested: Schema, random_i
assert new_schema
assert new_schema == update._apply()
assert new_schema.find_field("b").field_type == IntegerType()


@pytest.mark.parametrize(
'catalog',
[
lazy_fixture('catalog_memory'),
lazy_fixture('catalog_sqlite'),
lazy_fixture('catalog_sqlite_without_rowcount'),
],
)
def test_concurrent_commit_table(catalog: SqlCatalog, table_schema_simple: Schema, random_identifier: Identifier) -> None:
database_name, _table_name = random_identifier
catalog.create_namespace(database_name)
table_a = catalog.create_table(random_identifier, table_schema_simple)
table_b = catalog.load_table(random_identifier)

with table_a.update_schema() as update:
update.add_column(path="b", field_type=IntegerType())

with pytest.raises(CommitFailedException, match="Requirement failed: current schema id has changed: expected 0, found 1"):
# This one should fail since it already has been updated
with table_b.update_schema() as update:
update.add_column(path="c", field_type=IntegerType())

0 comments on commit 8614ba0

Please sign in to comment.