@@ -1437,3 +1437,56 @@ def test_remove_partition_statistics_update_with_invalid_snapshot_id(table_v2_wi
14371437 table_v2_with_statistics .metadata ,
14381438 (RemovePartitionStatisticsUpdate (snapshot_id = 123456789 ),),
14391439 )
1440+
1441+ def test_add_snapshot_update_fails_without_first_row_id (table_v3 : Table ) -> None :
1442+ new_snapshot = Snapshot (
1443+ snapshot_id = 25 ,
1444+ parent_snapshot_id = 19 ,
1445+ sequence_number = 200 ,
1446+ timestamp_ms = 1602638593590 ,
1447+ manifest_list = "s3:/a/b/c.avro" ,
1448+ summary = Summary (Operation .APPEND ),
1449+ schema_id = 3 ,
1450+ )
1451+
1452+ with pytest .raises (
1453+ ValueError ,
1454+ match = "Cannot add snapshot without first row id" ,
1455+ ):
1456+ update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1457+
1458+
1459+ def test_add_snapshot_update_fails_with_smaller_first_row_id (table_v3 : Table ) -> None :
1460+ new_snapshot = Snapshot (
1461+ snapshot_id = 25 ,
1462+ parent_snapshot_id = 19 ,
1463+ sequence_number = 200 ,
1464+ timestamp_ms = 1602638593590 ,
1465+ manifest_list = "s3:/a/b/c.avro" ,
1466+ summary = Summary (Operation .APPEND ),
1467+ schema_id = 3 ,
1468+ first_row_id = 0 ,
1469+ )
1470+
1471+ with pytest .raises (
1472+ ValueError ,
1473+ match = "Cannot add a snapshot with first row id smaller than the table's next-row-id" ,
1474+ ):
1475+ update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1476+
1477+
1478+ def test_add_snapshot_update_updates_next_row_id (table_v3 : Table ) -> None :
1479+ new_snapshot = Snapshot (
1480+ snapshot_id = 25 ,
1481+ parent_snapshot_id = 19 ,
1482+ sequence_number = 200 ,
1483+ timestamp_ms = 1602638593590 ,
1484+ manifest_list = "s3:/a/b/c.avro" ,
1485+ summary = Summary (Operation .APPEND ),
1486+ schema_id = 3 ,
1487+ first_row_id = 2 ,
1488+ added_rows = 10 ,
1489+ )
1490+
1491+ new_metadata = update_table_metadata (table_v3 .metadata , (AddSnapshotUpdate (snapshot = new_snapshot ),))
1492+ assert new_metadata .next_row_id == 11
0 commit comments