@@ -72,7 +72,13 @@ impl ManifestWriterBuilder {
72
72
. format_version ( FormatVersion :: V1 )
73
73
. content ( ManifestContentType :: Data )
74
74
. build ( ) ;
75
- ManifestWriter :: new ( self . output , self . snapshot_id , self . key_metadata , metadata)
75
+ ManifestWriter :: new (
76
+ self . output ,
77
+ self . snapshot_id ,
78
+ self . key_metadata ,
79
+ metadata,
80
+ None ,
81
+ )
76
82
}
77
83
78
84
/// Build a [`ManifestWriter`] for format version 2, data content.
@@ -84,7 +90,13 @@ impl ManifestWriterBuilder {
84
90
. format_version ( FormatVersion :: V2 )
85
91
. content ( ManifestContentType :: Data )
86
92
. build ( ) ;
87
- ManifestWriter :: new ( self . output , self . snapshot_id , self . key_metadata , metadata)
93
+ ManifestWriter :: new (
94
+ self . output ,
95
+ self . snapshot_id ,
96
+ self . key_metadata ,
97
+ metadata,
98
+ None ,
99
+ )
88
100
}
89
101
90
102
/// Build a [`ManifestWriter`] for format version 2, deletes content.
@@ -96,7 +108,51 @@ impl ManifestWriterBuilder {
96
108
. format_version ( FormatVersion :: V2 )
97
109
. content ( ManifestContentType :: Deletes )
98
110
. build ( ) ;
99
- ManifestWriter :: new ( self . output , self . snapshot_id , self . key_metadata , metadata)
111
+ ManifestWriter :: new (
112
+ self . output ,
113
+ self . snapshot_id ,
114
+ self . key_metadata ,
115
+ metadata,
116
+ None ,
117
+ )
118
+ }
119
+
120
+ /// Build a [`ManifestWriter`] for format version 2, data content.
121
+ pub fn build_v3_data ( self ) -> ManifestWriter {
122
+ let metadata = ManifestMetadata :: builder ( )
123
+ . schema_id ( self . schema . schema_id ( ) )
124
+ . schema ( self . schema )
125
+ . partition_spec ( self . partition_spec )
126
+ . format_version ( FormatVersion :: V3 )
127
+ . content ( ManifestContentType :: Data )
128
+ . build ( ) ;
129
+ ManifestWriter :: new (
130
+ self . output ,
131
+ self . snapshot_id ,
132
+ self . key_metadata ,
133
+ metadata,
134
+ // First row id is assigned by the [`ManifestListWriter`] when the manifest
135
+ // is added to the list.
136
+ None ,
137
+ )
138
+ }
139
+
140
+ /// Build a [`ManifestWriter`] for format version 2, deletes content.
141
+ pub fn build_v3_deletes ( self ) -> ManifestWriter {
142
+ let metadata = ManifestMetadata :: builder ( )
143
+ . schema_id ( self . schema . schema_id ( ) )
144
+ . schema ( self . schema )
145
+ . partition_spec ( self . partition_spec )
146
+ . format_version ( FormatVersion :: V3 )
147
+ . content ( ManifestContentType :: Deletes )
148
+ . build ( ) ;
149
+ ManifestWriter :: new (
150
+ self . output ,
151
+ self . snapshot_id ,
152
+ self . key_metadata ,
153
+ metadata,
154
+ None ,
155
+ )
100
156
}
101
157
}
102
158
@@ -112,6 +168,7 @@ pub struct ManifestWriter {
112
168
existing_rows : u64 ,
113
169
deleted_files : u32 ,
114
170
deleted_rows : u64 ,
171
+ first_row_id : Option < u64 > ,
115
172
116
173
min_seq_num : Option < i64 > ,
117
174
@@ -129,6 +186,7 @@ impl ManifestWriter {
129
186
snapshot_id : Option < i64 > ,
130
187
key_metadata : Option < Vec < u8 > > ,
131
188
metadata : ManifestMetadata ,
189
+ first_row_id : Option < u64 > ,
132
190
) -> Self {
133
191
Self {
134
192
output,
@@ -139,6 +197,7 @@ impl ManifestWriter {
139
197
existing_rows : 0 ,
140
198
deleted_files : 0 ,
141
199
deleted_rows : 0 ,
200
+ first_row_id,
142
201
min_seq_num : None ,
143
202
key_metadata,
144
203
manifest_entries : Vec :: new ( ) ,
@@ -348,7 +407,8 @@ impl ManifestWriter {
348
407
let table_schema = & self . metadata . schema ;
349
408
let avro_schema = match self . metadata . format_version {
350
409
FormatVersion :: V1 => manifest_schema_v1 ( & partition_type) ?,
351
- FormatVersion :: V2 => manifest_schema_v2 ( & partition_type) ?,
410
+ // Manifest schema did not change between V2 and V3
411
+ FormatVersion :: V2 | FormatVersion :: V3 => manifest_schema_v2 ( & partition_type) ?,
352
412
} ;
353
413
let mut avro_writer = AvroWriter :: new ( & avro_schema, Vec :: new ( ) ) ;
354
414
avro_writer. add_user_metadata (
@@ -388,8 +448,11 @@ impl ManifestWriter {
388
448
let value = match self . metadata . format_version {
389
449
FormatVersion :: V1 => to_value ( ManifestEntryV1 :: try_from ( entry, & partition_type) ?) ?
390
450
. resolve ( & avro_schema) ?,
391
- FormatVersion :: V2 => to_value ( ManifestEntryV2 :: try_from ( entry, & partition_type) ?) ?
392
- . resolve ( & avro_schema) ?,
451
+ // Manifest entry format did not change between V2 and V3
452
+ FormatVersion :: V2 | FormatVersion :: V3 => {
453
+ to_value ( ManifestEntryV2 :: try_from ( entry, & partition_type) ?) ?
454
+ . resolve ( & avro_schema) ?
455
+ }
393
456
} ;
394
457
395
458
avro_writer. append ( value) ?;
@@ -417,6 +480,7 @@ impl ManifestWriter {
417
480
deleted_rows_count : Some ( self . deleted_rows ) ,
418
481
partitions : Some ( partition_summary) ,
419
482
key_metadata : self . key_metadata ,
483
+ first_row_id : self . first_row_id ,
420
484
} )
421
485
}
422
486
}
0 commit comments