@@ -796,6 +796,10 @@ pub(super) mod _serde {
796
796
summary : Summary ,
797
797
#[ serde( skip_serializing_if = "Option::is_none" ) ]
798
798
schema_id : Option < SchemaId > ,
799
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
800
+ first_row_id : Option < u64 > ,
801
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
802
+ added_rows : Option < u64 > ,
799
803
}
800
804
801
805
impl From < CatalogSnapshot > for Snapshot {
@@ -808,6 +812,8 @@ pub(super) mod _serde {
808
812
manifest_list,
809
813
schema_id,
810
814
summary,
815
+ first_row_id,
816
+ added_rows,
811
817
} = snapshot;
812
818
let builder = Snapshot :: builder ( )
813
819
. with_snapshot_id ( snapshot_id)
@@ -816,10 +822,17 @@ pub(super) mod _serde {
816
822
. with_timestamp_ms ( timestamp_ms)
817
823
. with_manifest_list ( manifest_list)
818
824
. with_summary ( summary) ;
819
- if let Some ( schema_id) = schema_id {
820
- builder. with_schema_id ( schema_id) . build ( )
821
- } else {
822
- builder. build ( )
825
+ let row_range = first_row_id. zip ( added_rows) ;
826
+ match ( schema_id, row_range) {
827
+ ( None , None ) => builder. build ( ) ,
828
+ ( Some ( schema_id) , None ) => builder. with_schema_id ( schema_id) . build ( ) ,
829
+ ( None , Some ( ( first_row_id, last_row_id) ) ) => {
830
+ builder. with_row_range ( first_row_id, last_row_id) . build ( )
831
+ }
832
+ ( Some ( schema_id) , Some ( ( first_row_id, last_row_id) ) ) => builder
833
+ . with_schema_id ( schema_id)
834
+ . with_row_range ( first_row_id, last_row_id)
835
+ . build ( ) ,
823
836
}
824
837
}
825
838
}
@@ -1692,6 +1705,44 @@ mod tests {
1692
1705
assert_eq ! ( actual, update, "Parsed value is not equal to expected" ) ;
1693
1706
}
1694
1707
1708
+ #[ test]
1709
+ fn test_add_snapshot_with_row_lineage ( ) {
1710
+ let json = r#"
1711
+ {
1712
+ "action": "add-snapshot",
1713
+ "snapshot": {
1714
+ "snapshot-id": 3055729675574597000,
1715
+ "parent-snapshot-id": 3051729675574597000,
1716
+ "timestamp-ms": 1555100955770,
1717
+ "first-row-id":0,
1718
+ "added-rows":2,
1719
+ "summary": {
1720
+ "operation": "append"
1721
+ },
1722
+ "manifest-list": "s3://a/b/2.avro"
1723
+ }
1724
+ }
1725
+ "# ;
1726
+
1727
+ let update = TableUpdate :: AddSnapshot {
1728
+ snapshot : Snapshot :: builder ( )
1729
+ . with_snapshot_id ( 3055729675574597000 )
1730
+ . with_parent_snapshot_id ( Some ( 3051729675574597000 ) )
1731
+ . with_timestamp_ms ( 1555100955770 )
1732
+ . with_sequence_number ( 0 )
1733
+ . with_manifest_list ( "s3://a/b/2.avro" )
1734
+ . with_row_range ( 0 , 2 )
1735
+ . with_summary ( Summary {
1736
+ operation : Operation :: Append ,
1737
+ additional_properties : HashMap :: default ( ) ,
1738
+ } )
1739
+ . build ( ) ,
1740
+ } ;
1741
+
1742
+ let actual: TableUpdate = serde_json:: from_str ( json) . expect ( "Failed to parse from json" ) ;
1743
+ assert_eq ! ( actual, update, "Parsed value is not equal to expected" ) ;
1744
+ }
1745
+
1695
1746
#[ test]
1696
1747
fn test_remove_snapshots ( ) {
1697
1748
let json = r#"
0 commit comments