Skip to content

Commit a810a15

Browse files
Consolidate replace integration tests into single RTAS path
The DDL-only integration test only added one unique invariant beyond the RTAS test: that current_snapshot_id is None after a replace with no follow-up append. That invariant is already covered at the catalog-behavior layer (test_replace_transaction) against InMemoryCatalog + SqlCatalog. Backends don't differentiate "DDL-only commit" from "DDL+write commit" at the protocol level, so a separate integration variant adds little signal. Fold the UUID-preservation assertion (which the RTAS test wasn't checking explicitly) into the consolidated test.
1 parent 5b4a49a commit a810a15

1 file changed

Lines changed: 2 additions & 38 deletions

File tree

tests/integration/test_catalog.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from pyiceberg.table.metadata import INITIAL_SPEC_ID
4545
from pyiceberg.table.sorting import INITIAL_SORT_ORDER_ID, SortField, SortOrder
4646
from pyiceberg.transforms import BucketTransform, DayTransform, IdentityTransform
47-
from pyiceberg.types import BooleanType, IntegerType, LongType, NestedField, StringType, TimestampType, UUIDType
47+
from pyiceberg.types import IntegerType, LongType, NestedField, TimestampType, UUIDType
4848
from tests.conftest import (
4949
clean_up,
5050
does_support_atomic_concurrent_updates,
@@ -877,43 +877,6 @@ def test_load_missing_table(test_catalog: Catalog, database_name: str, table_nam
877877
test_catalog.load_table(identifier)
878878

879879

880-
@pytest.mark.integration
881-
@pytest.mark.parametrize("test_catalog", CATALOGS)
882-
def test_replace_table(test_catalog: Catalog, database_name: str, table_name: str) -> None:
883-
test_catalog.create_namespace(database_name)
884-
identifier = (database_name, table_name)
885-
886-
original_schema = Schema(
887-
NestedField(field_id=1, name="id", field_type=LongType(), required=False),
888-
NestedField(field_id=2, name="data", field_type=StringType(), required=False),
889-
)
890-
original = test_catalog.create_table(identifier, schema=original_schema)
891-
original.append(
892-
pa.Table.from_pydict(
893-
{"id": [1, 2, 3], "data": ["a", "b", "c"]},
894-
schema=pa.schema([pa.field("id", pa.int64()), pa.field("data", pa.large_string())]),
895-
)
896-
)
897-
original.refresh()
898-
original_snapshot_id = original.current_snapshot().snapshot_id # type: ignore[union-attr]
899-
900-
new_schema = Schema(
901-
NestedField(field_id=1, name="id", field_type=LongType(), required=False),
902-
NestedField(field_id=2, name="name", field_type=StringType(), required=False),
903-
NestedField(field_id=3, name="active", field_type=BooleanType(), required=False),
904-
)
905-
test_catalog.replace_table_transaction(identifier, schema=new_schema).commit_transaction()
906-
replaced = test_catalog.load_table(identifier)
907-
908-
assert replaced.metadata.table_uuid == original.metadata.table_uuid
909-
assert replaced.current_snapshot() is None
910-
assert any(s.snapshot_id == original_snapshot_id for s in replaced.metadata.snapshots)
911-
# Time-travel back to the pre-replace snapshot returns the rows that were there before.
912-
time_travel = replaced.scan(snapshot_id=original_snapshot_id).to_arrow()
913-
assert time_travel.num_rows == 3
914-
assert sorted(time_travel.column("id").to_pylist()) == [1, 2, 3]
915-
916-
917880
@pytest.mark.integration
918881
@pytest.mark.parametrize("test_catalog", CATALOGS)
919882
def test_replace_table_transaction(test_catalog: Catalog, database_name: str, table_name: str) -> None:
@@ -936,6 +899,7 @@ def test_replace_table_transaction(test_catalog: Catalog, database_name: str, ta
936899
txn.append(new_data)
937900

938901
replaced = test_catalog.load_table(identifier)
902+
assert replaced.metadata.table_uuid == original.metadata.table_uuid
939903
assert replaced.current_snapshot() is not None
940904
assert replaced.current_snapshot().snapshot_id != old_snapshot_id # type: ignore[union-attr]
941905
assert any(s.snapshot_id == old_snapshot_id for s in replaced.metadata.snapshots)

0 commit comments

Comments
 (0)