diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index a92d944811..470c99d602 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -1087,18 +1087,15 @@ def add_entry(self, entry: ManifestEntry) -> ManifestWriter: return self def add(self, entry: ManifestEntry) -> ManifestWriter: - if entry.sequence_number is not None and entry.sequence_number >= 0: - self.add_entry( - ManifestEntry.from_args( - snapshot_id=self._snapshot_id, sequence_number=entry.sequence_number, data_file=entry.data_file - ) - ) - else: - self.add_entry( - ManifestEntry.from_args( - status=ManifestEntryStatus.ADDED, snapshot_id=self._snapshot_id, data_file=entry.data_file - ) + self.add_entry( + ManifestEntry.from_args( + status=ManifestEntryStatus.ADDED, + snapshot_id=self._snapshot_id, + sequence_number=entry.sequence_number if entry.sequence_number != UNASSIGNED_SEQ else None, + data_file=entry.data_file, ) + ) + return self def delete(self, entry: ManifestEntry) -> ManifestWriter: diff --git a/tests/catalog/test_sql.py b/tests/catalog/test_sql.py index 27105e8004..00868a5739 100644 --- a/tests/catalog/test_sql.py +++ b/tests/catalog/test_sql.py @@ -1657,6 +1657,10 @@ def test_merge_manifests_local_file_system(catalog: SqlCatalog, arrow_table_with tbl.append(arrow_table_with_null) assert len(tbl.scan().to_arrow()) == 5 * len(arrow_table_with_null) + current_snapshot = tbl.current_snapshot() + assert current_snapshot + manifests = current_snapshot.manifests(tbl.io) + assert len(manifests) == 1 @pytest.mark.parametrize(