Skip to content

Commit 7acdb12

Browse files
Fokkokevinjqliu
andauthored
Set the ManifestEntryStatus (#2408)
A faulty refactor: 59742e0#diff-e9df836e263024ba54e2706853fb25c00269fbfe3726b440ba57f4a929c995dcR927 This produces incorrect metadata, but was hidden by the writer. <!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change ## Are these changes tested? ## Are there any user-facing changes? <!-- In the case of user-facing changes, please add the changelog label. --> --------- Co-authored-by: Kevin Liu <[email protected]>
1 parent 38c569b commit 7acdb12

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

pyiceberg/manifest.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,18 +1087,15 @@ def add_entry(self, entry: ManifestEntry) -> ManifestWriter:
10871087
return self
10881088

10891089
def add(self, entry: ManifestEntry) -> ManifestWriter:
1090-
if entry.sequence_number is not None and entry.sequence_number >= 0:
1091-
self.add_entry(
1092-
ManifestEntry.from_args(
1093-
snapshot_id=self._snapshot_id, sequence_number=entry.sequence_number, data_file=entry.data_file
1094-
)
1095-
)
1096-
else:
1097-
self.add_entry(
1098-
ManifestEntry.from_args(
1099-
status=ManifestEntryStatus.ADDED, snapshot_id=self._snapshot_id, data_file=entry.data_file
1100-
)
1090+
self.add_entry(
1091+
ManifestEntry.from_args(
1092+
status=ManifestEntryStatus.ADDED,
1093+
snapshot_id=self._snapshot_id,
1094+
sequence_number=entry.sequence_number if entry.sequence_number != UNASSIGNED_SEQ else None,
1095+
data_file=entry.data_file,
11011096
)
1097+
)
1098+
11021099
return self
11031100

11041101
def delete(self, entry: ManifestEntry) -> ManifestWriter:

tests/catalog/test_sql.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,10 @@ def test_merge_manifests_local_file_system(catalog: SqlCatalog, arrow_table_with
16571657
tbl.append(arrow_table_with_null)
16581658

16591659
assert len(tbl.scan().to_arrow()) == 5 * len(arrow_table_with_null)
1660+
current_snapshot = tbl.current_snapshot()
1661+
assert current_snapshot
1662+
manifests = current_snapshot.manifests(tbl.io)
1663+
assert len(manifests) == 1
16601664

16611665

16621666
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)