Skip to content

Commit c554bda

Browse files
committed
Fix lint and move tests to test_deletes
1 parent 658c012 commit c554bda

File tree

2 files changed

+53
-83
lines changed

2 files changed

+53
-83
lines changed

tests/integration/test_deletes.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from pyiceberg.catalog.rest import RestCatalog
2626
from pyiceberg.exceptions import NoSuchTableError
27-
from pyiceberg.expressions import AlwaysTrue, EqualTo
27+
from pyiceberg.expressions import AlwaysTrue, EqualTo, LessThanOrEqual
2828
from pyiceberg.manifest import ManifestEntryStatus
2929
from pyiceberg.partitioning import PartitionField, PartitionSpec
3030
from pyiceberg.schema import Schema
@@ -923,3 +923,55 @@ def test_delete_on_empty_table(spark: SparkSession, session_catalog: RestCatalog
923923

924924
# Assert that no new snapshot was created because no rows were deleted
925925
assert len(tbl.snapshots()) == 0
926+
927+
928+
@pytest.mark.integration
929+
def test_manifest_entry_after_deletes(session_catalog: RestCatalog) -> None:
930+
identifier = "default.test_manifest_entry_after_deletes"
931+
try:
932+
session_catalog.drop_table(identifier)
933+
except NoSuchTableError:
934+
pass
935+
936+
schema = pa.schema(
937+
[
938+
("id", pa.int32()),
939+
("name", pa.string()),
940+
]
941+
)
942+
943+
table = session_catalog.create_table(identifier, schema)
944+
data = pa.Table.from_pylist(
945+
[
946+
{"id": 1, "name": "foo"},
947+
{"id": 2, "name": "bar"},
948+
{"id": 3, "name": "bar"},
949+
{"id": 4, "name": "bar"},
950+
],
951+
schema=schema,
952+
)
953+
table.append(data)
954+
955+
def assert_manifest_entry(expected_status: ManifestEntryStatus, expected_snapshot_id: int) -> None:
956+
current_snapshot = table.refresh().current_snapshot()
957+
assert current_snapshot is not None
958+
959+
manifest_files = current_snapshot.manifests(table.io)
960+
assert len(manifest_files) == 1
961+
962+
entries = manifest_files[0].fetch_manifest_entry(table.io, discard_deleted=False)
963+
assert len(entries) == 1
964+
entry = entries[0]
965+
assert entry.status == expected_status
966+
assert entry.snapshot_id == expected_snapshot_id
967+
968+
before_delete_snapshot = table.current_snapshot()
969+
assert before_delete_snapshot is not None
970+
971+
assert_manifest_entry(ManifestEntryStatus.ADDED, before_delete_snapshot.snapshot_id)
972+
973+
table.delete(LessThanOrEqual("id", 4))
974+
after_delete_snapshot = table.refresh().current_snapshot()
975+
assert after_delete_snapshot is not None
976+
977+
assert_manifest_entry(ManifestEntryStatus.DELETED, after_delete_snapshot.snapshot_id)

tests/table/test_delete.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)