Skip to content

Commit 66f4a68

Browse files
Add time-travel assertion to replace integration tests
The .append() before replace exists to produce a snapshot. The existing assertion ('old snapshot id in metadata.snapshots') only proves the metadata entry survived — not that it's actually readable. Adding a scan(snapshot_id=old_snapshot_id) round-trip proves the schema + manifest references for the pre-replace snapshot are still resolvable through the real object store, not just present in the metadata document.
1 parent 242f414 commit 66f4a68

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/integration/test_catalog.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,10 @@ def test_replace_table(test_catalog: Catalog, database_name: str, table_name: st
907907
assert replaced.metadata.table_uuid == original.metadata.table_uuid
908908
assert replaced.current_snapshot() is None
909909
assert any(s.snapshot_id == original_snapshot_id for s in replaced.metadata.snapshots)
910+
# Time-travel back to the pre-replace snapshot returns the rows that were there before.
911+
time_travel = replaced.scan(snapshot_id=original_snapshot_id).to_arrow()
912+
assert time_travel.num_rows == 3
913+
assert sorted(time_travel.column("id").to_pylist()) == [1, 2, 3]
910914

911915

912916
@pytest.mark.integration
@@ -935,3 +939,7 @@ def test_replace_table_transaction(test_catalog: Catalog, database_name: str, ta
935939
assert replaced.current_snapshot().snapshot_id != old_snapshot_id # type: ignore[union-attr]
936940
assert any(s.snapshot_id == old_snapshot_id for s in replaced.metadata.snapshots)
937941
assert replaced.scan().to_arrow().num_rows == 2
942+
# Time-travel back to the pre-replace snapshot returns the original row.
943+
old_via_time_travel = replaced.scan(snapshot_id=old_snapshot_id).to_arrow()
944+
assert old_via_time_travel.num_rows == 1
945+
assert old_via_time_travel.column("id").to_pylist() == [1]

0 commit comments

Comments
 (0)