@@ -118,18 +118,20 @@ impl ManifestListWriter {
118118 pub fn v2 (
119119 output_file : OutputFile ,
120120 snapshot_id : i64 ,
121- parent_snapshot_id : i64 ,
121+ parent_snapshot_id : Option < i64 > ,
122122 sequence_number : i64 ,
123123 ) -> Self {
124- let metadata = HashMap :: from_iter ( [
124+ let mut metadata = HashMap :: from_iter ( [
125125 ( "snapshot-id" . to_string ( ) , snapshot_id. to_string ( ) ) ,
126- (
127- "parent-snapshot-id" . to_string ( ) ,
128- parent_snapshot_id. to_string ( ) ,
129- ) ,
130126 ( "sequence-number" . to_string ( ) , sequence_number. to_string ( ) ) ,
131127 ( "format-version" . to_string ( ) , "2" . to_string ( ) ) ,
132128 ] ) ;
129+ if let Some ( parent_snapshot_id) = parent_snapshot_id {
130+ metadata. insert (
131+ "parent-snapshot-id" . to_string ( ) ,
132+ parent_snapshot_id. to_string ( ) ,
133+ ) ;
134+ }
133135 Self :: new (
134136 FormatVersion :: V2 ,
135137 output_file,
@@ -1204,7 +1206,7 @@ mod test {
12041206 let mut writer = ManifestListWriter :: v2 (
12051207 file_io. new_output ( full_path. clone ( ) ) . unwrap ( ) ,
12061208 1646658105718557341 ,
1207- 1646658105718557341 ,
1209+ Some ( 1646658105718557341 ) ,
12081210 1 ,
12091211 ) ;
12101212
@@ -1382,7 +1384,7 @@ mod test {
13821384 let io = FileIOBuilder :: new_fs_io ( ) . build ( ) . unwrap ( ) ;
13831385 let output_file = io. new_output ( path. to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
13841386
1385- let mut writer = ManifestListWriter :: v2 ( output_file, snapshot_id, 0 , seq_num) ;
1387+ let mut writer = ManifestListWriter :: v2 ( output_file, snapshot_id, Some ( 0 ) , seq_num) ;
13861388 writer
13871389 . add_manifests ( expected_manifest_list. entries . clone ( ) . into_iter ( ) )
13881390 . unwrap ( ) ;
@@ -1436,7 +1438,7 @@ mod test {
14361438 let io = FileIOBuilder :: new_fs_io ( ) . build ( ) . unwrap ( ) ;
14371439 let output_file = io. new_output ( path. to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
14381440
1439- let mut writer = ManifestListWriter :: v2 ( output_file, 1646658105718557341 , 0 , 1 ) ;
1441+ let mut writer = ManifestListWriter :: v2 ( output_file, 1646658105718557341 , Some ( 0 ) , 1 ) ;
14401442 writer
14411443 . add_manifests ( expected_manifest_list. entries . clone ( ) . into_iter ( ) )
14421444 . unwrap ( ) ;
0 commit comments