@@ -737,3 +737,40 @@ def test_overwrite_rejects_explicit_delete_without_parent_snapshot(
737737 with empty .transaction () as tx :
738738 with tx .update_snapshot ().overwrite () as overwrite :
739739 overwrite .delete_data_file (stale_file )
740+
741+
742+ def test_manifest_list_receives_first_row_id_for_v3 (table_v3 : Table ) -> None :
743+ """The V3 manifest list writer requires first-row-id, so the producer has to supply it."""
744+ from unittest import mock
745+
746+ from pyiceberg .table .update .snapshot import _FastAppendFiles
747+
748+ txn = table_v3 .transaction ()
749+ append = _FastAppendFiles (operation = Operation .APPEND , transaction = txn , io = table_v3 .io )
750+
751+ with (
752+ mock .patch ("pyiceberg.table.update.snapshot.write_manifest_list" ) as writer ,
753+ mock .patch .object (_FastAppendFiles , "_manifests" , return_value = []),
754+ ):
755+ append ._commit ()
756+
757+ assert writer .call_args .kwargs ["format_version" ] == 3
758+ assert writer .call_args .kwargs ["first_row_id" ] == table_v3 .metadata .next_row_id
759+
760+
761+ def test_manifest_list_has_no_first_row_id_for_v2 (table_v2 : Table ) -> None :
762+ from unittest import mock
763+
764+ from pyiceberg .table .update .snapshot import _FastAppendFiles
765+
766+ txn = table_v2 .transaction ()
767+ append = _FastAppendFiles (operation = Operation .APPEND , transaction = txn , io = table_v2 .io )
768+
769+ with (
770+ mock .patch ("pyiceberg.table.update.snapshot.write_manifest_list" ) as writer ,
771+ mock .patch .object (_FastAppendFiles , "_manifests" , return_value = []),
772+ ):
773+ append ._commit ()
774+
775+ assert writer .call_args .kwargs ["format_version" ] == 2
776+ assert writer .call_args .kwargs ["first_row_id" ] is None
0 commit comments