From 2ee4a7c37498e17b60a4882daa5636456c74b719 Mon Sep 17 00:00:00 2001 From: Sotaro Hikita Date: Sun, 19 Apr 2026 03:50:54 +0900 Subject: [PATCH] Fix ManifestEntry.snapshot_id setter writing to wrong index The setter wrote to self._data[0] (status) instead of self._data[1] (snapshot_id), corrupting the status field and leaving snapshot_id unchanged when _inherit_from_manifest() assigned the inherited value. Signed-off-by: Sotaro Hikita --- pyiceberg/manifest.py | 2 +- tests/utils/test_manifest.py | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index cca0af7628..3811a9d894 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -614,7 +614,7 @@ def snapshot_id(self) -> int | None: @snapshot_id.setter def snapshot_id(self, value: int) -> None: - self._data[0] = value + self._data[1] = value @property def sequence_number(self) -> int | None: diff --git a/tests/utils/test_manifest.py b/tests/utils/test_manifest.py index 3f859b3b32..b16bddd6d0 100644 --- a/tests/utils/test_manifest.py +++ b/tests/utils/test_manifest.py @@ -32,6 +32,7 @@ ManifestEntryStatus, ManifestFile, PartitionFieldSummary, + _inherit_from_manifest, _manifest_cache, _manifests, read_manifest_list, @@ -932,3 +933,43 @@ def test_manifest_writer_tell(format_version: TableVersion) -> None: after_entry_bytes = writer.tell() assert after_entry_bytes > initial_bytes, "Bytes should increase after adding entry" + + +def test_inherit_from_manifest_snapshot_id() -> None: + entry = ManifestEntry.from_args( + status=ManifestEntryStatus.ADDED, + snapshot_id=None, + sequence_number=None, + file_sequence_number=None, + data_file=DataFile.from_args( + content=DataFileContent.DATA, + file_path="s3://bucket/data/file.parquet", + file_format="PARQUET", + partition={}, + record_count=100, + file_size_in_bytes=1024, + ), + ) + + manifest = ManifestFile.from_args( + manifest_path="s3://bucket/metadata/manifest.avro", + manifest_length=1000, + partition_spec_id=0, + content=ManifestContent.DATA, + sequence_number=1, + min_sequence_number=1, + added_snapshot_id=3051729675574597004, + added_files_count=1, + existing_files_count=0, + deleted_files_count=0, + added_rows_count=100, + existing_rows_count=0, + deleted_rows_count=0, + ) + + result = _inherit_from_manifest(entry, manifest) + + assert result.status == ManifestEntryStatus.ADDED + assert result.snapshot_id == 3051729675574597004 + assert result.sequence_number == 1 + assert result.file_sequence_number == 1