Skip to content

Commit 99dcfb5

Browse files
Guard the compaction test against a no-op rewrite
rewrite_data_files commits no snapshot when there's nothing to compact, which would silently shift the fixture's snapshot indices and make the double-count test scan to the wrong (also non-append) snapshot while still passing. Assert snapshots[3] really is the compaction (operation=replace) so a no-op fails loudly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7f675ab commit 99dcfb5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/integration/test_reads.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
)
5252
from pyiceberg.schema import Schema
5353
from pyiceberg.table import Table
54+
from pyiceberg.table.snapshots import Operation
5455
from pyiceberg.types import (
5556
BinaryType,
5657
BooleanType,
@@ -1318,6 +1319,12 @@ def test_incremental_append_scan_does_not_double_count_compacted_files(catalog:
13181319
# compacts them into a single rewritten file. A scan spanning the compaction must read each
13191320
# appended row exactly once -- the rewritten file (added by the compaction, not by an append)
13201321
# must not be picked up on top of the originals.
1322+
#
1323+
# Guard the fixture: rewrite_data_files is a no-op (no snapshot) when there's nothing to
1324+
# compact, which would silently shift the indices and make this test scan to the wrong
1325+
# snapshot. Assert snapshots[3] really is the compaction.
1326+
assert test_table.snapshots()[3].summary.operation == Operation.REPLACE # type: ignore[union-attr]
1327+
13211328
scan = test_table.incremental_append_scan(
13221329
from_snapshot_id_exclusive=test_table.snapshots()[0].snapshot_id,
13231330
to_snapshot_id_inclusive=test_table.snapshots()[3].snapshot_id,

0 commit comments

Comments
 (0)