@@ -1521,3 +1521,56 @@ def test_remove_partition_statistics_update_with_invalid_snapshot_id(table_v2_wi
15211521 table_v2_with_statistics .metadata ,
15221522 (RemovePartitionStatisticsUpdate (snapshot_id = 123456789 ),),
15231523 )
1524+
1525+ def test_add_snapshot_update_fails_without_first_row_id (table_v3 : Table ) -> None :
1526+ new_snapshot = Snapshot (
1527+ snapshot_id = 25 ,
1528+ parent_snapshot_id = 19 ,
1529+ sequence_number = 200 ,
1530+ timestamp_ms = 1602638593590 ,
1531+ manifest_list = "s3:/a/b/c.avro" ,
1532+ summary = Summary (Operation .APPEND ),
1533+ schema_id = 3 ,
1534+ )
1535+
1536+ with pytest .raises (
1537+ ValueError ,
1538+ match = "Cannot add snapshot without first row id" ,
1539+ ):
1540+ update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1541+
1542+
1543+ def test_add_snapshot_update_fails_with_smaller_first_row_id (table_v3 : Table ) -> None :
1544+ new_snapshot = Snapshot (
1545+ snapshot_id = 25 ,
1546+ parent_snapshot_id = 19 ,
1547+ sequence_number = 200 ,
1548+ timestamp_ms = 1602638593590 ,
1549+ manifest_list = "s3:/a/b/c.avro" ,
1550+ summary = Summary (Operation .APPEND ),
1551+ schema_id = 3 ,
1552+ first_row_id = 0 ,
1553+ )
1554+
1555+ with pytest .raises (
1556+ ValueError ,
1557+ match = "Cannot add a snapshot with first row id smaller than the table's next-row-id" ,
1558+ ):
1559+ update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1560+
1561+
1562+ def test_add_snapshot_update_updates_next_row_id (table_v3 : Table ) -> None :
1563+ new_snapshot = Snapshot (
1564+ snapshot_id = 25 ,
1565+ parent_snapshot_id = 19 ,
1566+ sequence_number = 200 ,
1567+ timestamp_ms = 1602638593590 ,
1568+ manifest_list = "s3:/a/b/c.avro" ,
1569+ summary = Summary (Operation .APPEND ),
1570+ schema_id = 3 ,
1571+ first_row_id = 2 ,
1572+ added_rows = 10 ,
1573+ )
1574+
1575+ new_metadata = update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1576+ assert new_metadata .next_row_id == 11
0 commit comments