Repository navigation
Support writing V3 manifests and manifest lists #3624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,21 +348,22 @@ def _commit(self) -> UpdatesAndRequirements: | |
| manifest_list_file_path = location_provider.new_metadata_location(file_name) | ||
| self._written_manifest_lists.append(manifest_list_file_path) | ||
|
|
||
| first_row_id: int | None = None | ||
|
|
||
| if self._transaction.table_metadata.format_version >= 3: | ||
| first_row_id = self._transaction.table_metadata.next_row_id | ||
|
|
||
| with write_manifest_list( | ||
| format_version=self._transaction.table_metadata.format_version, | ||
| output_file=self._io.new_output(manifest_list_file_path), | ||
| snapshot_id=self._snapshot_id, | ||
| parent_snapshot_id=self._parent_snapshot_id, | ||
| sequence_number=next_sequence_number, | ||
| avro_compression=self._compression, | ||
| first_row_id=first_row_id, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we also need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're reading it right: since #3972, |
||
| ) as writer: | ||
| writer.add_manifests(new_manifests) | ||
|
|
||
| first_row_id: int | None = None | ||
|
|
||
| if self._transaction.table_metadata.format_version >= 3: | ||
| first_row_id = self._transaction.table_metadata.next_row_id | ||
|
|
||
| snapshot = Snapshot( | ||
| snapshot_id=self._snapshot_id, | ||
| parent_snapshot_id=self._parent_snapshot_id, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -844,3 +844,40 @@ def test_overwrite_rejects_explicit_delete_without_parent_snapshot( | |
| with empty.transaction() as tx: | ||
| with tx.update_snapshot().overwrite() as overwrite: | ||
| overwrite.delete_data_file(stale_file) | ||
|
|
||
|
|
||
| def test_manifest_list_receives_first_row_id_for_v3(table_v3: Table) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: would be nice to do a real
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. A real |
||
| """The V3 manifest list writer requires first-row-id, so the producer has to supply it.""" | ||
| from unittest import mock | ||
|
|
||
| from pyiceberg.table.update.snapshot import _FastAppendFiles | ||
|
|
||
| txn = table_v3.transaction() | ||
| append = _FastAppendFiles(operation=Operation.APPEND, transaction=txn, io=table_v3.io) | ||
|
|
||
| with ( | ||
| mock.patch("pyiceberg.table.update.snapshot.write_manifest_list") as writer, | ||
| mock.patch.object(_FastAppendFiles, "_manifests", return_value=[]), | ||
| ): | ||
| append._commit() | ||
|
|
||
| assert writer.call_args.kwargs["format_version"] == 3 | ||
| assert writer.call_args.kwargs["first_row_id"] == table_v3.metadata.next_row_id | ||
|
|
||
|
|
||
| def test_manifest_list_has_no_first_row_id_for_v2(table_v2: Table) -> None: | ||
| from unittest import mock | ||
|
|
||
| from pyiceberg.table.update.snapshot import _FastAppendFiles | ||
|
|
||
| txn = table_v2.transaction() | ||
| append = _FastAppendFiles(operation=Operation.APPEND, transaction=txn, io=table_v2.io) | ||
|
|
||
| with ( | ||
| mock.patch("pyiceberg.table.update.snapshot.write_manifest_list") as writer, | ||
| mock.patch.object(_FastAppendFiles, "_manifests", return_value=[]), | ||
| ): | ||
| append._commit() | ||
|
|
||
| assert writer.call_args.kwargs["format_version"] == 2 | ||
| assert writer.call_args.kwargs["first_row_id"] is None | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super().to_manifest_file()is already V3 layout so I think this can just bemanifest_file.first_row_id = self._first_row_id?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done:
to_manifest_filenow just setsmanifest_file.first_row_id = self._first_row_id.