Skip to content

Commit 0763056

Browse files
committed
raise error on summary operation being none in validation_history
1 parent a6624d9 commit 0763056

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

pyiceberg/table/update/validate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ def validation_history(
5151
last_snapshot = snapshot
5252
summary = snapshot.summary
5353
if summary is None:
54-
operation = Operation.OVERWRITE
55-
else:
56-
operation = summary.operation
57-
if operation not in matching_operations:
54+
raise ValidationException(f"No summary found for snapshot {snapshot}!")
55+
if summary.operation not in matching_operations:
5856
continue
5957

6058
if snapshot not in snapshots:

tests/table/test_validate.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
from typing import cast
1919
from unittest.mock import patch
2020

21+
import pytest
22+
23+
from pyiceberg.exceptions import ValidationException
2124
from pyiceberg.io import FileIO
2225
from pyiceberg.manifest import ManifestContent, ManifestFile
2326
from pyiceberg.table import Table
@@ -65,3 +68,21 @@ def mock_read_manifest_side_effect(self: Snapshot, io: FileIO) -> list[ManifestF
6568
)
6669

6770
assert len(manifests) == expected_manifest_data_counts
71+
72+
snapshot_with_no_summary = Snapshot(
73+
snapshot_id="1234",
74+
parent_id="5678",
75+
timestamp_ms=0,
76+
operation=Operation.APPEND,
77+
summary=None,
78+
manifest_list="foo/bar",
79+
)
80+
with patch("pyiceberg.table.update.validate.ancestors_between", return_value=[snapshot_with_no_summary]):
81+
with pytest.raises(ValidationException):
82+
validation_history(
83+
table_v2_with_extensive_snapshots,
84+
newest_snapshot,
85+
oldest_snapshot,
86+
{Operation.APPEND},
87+
ManifestContent.DATA,
88+
)

0 commit comments

Comments
 (0)