@@ -22,12 +22,12 @@ use std::ops::RangeFrom;
22
22
use uuid:: Uuid ;
23
23
24
24
use crate :: error:: Result ;
25
- use crate :: io:: OutputFile ;
26
25
use crate :: spec:: {
27
- DataFile , DataFileFormat , FormatVersion , MAIN_BRANCH , ManifestEntry , ManifestFile ,
28
- ManifestListWriter , ManifestWriterBuilder , Operation , PROPERTY_WRITE_PARTITION_SUMMARY_LIMIT ,
29
- PROPERTY_WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT , Snapshot , SnapshotReference , SnapshotRetention ,
30
- SnapshotSummaryCollector , Struct , StructType , Summary , update_snapshot_summaries,
26
+ DataFile , DataFileFormat , FormatVersion , MAIN_BRANCH , ManifestContentType , ManifestEntry ,
27
+ ManifestFile , ManifestListWriter , ManifestWriter , ManifestWriterBuilder , Operation ,
28
+ PROPERTY_WRITE_PARTITION_SUMMARY_LIMIT , PROPERTY_WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT ,
29
+ Snapshot , SnapshotReference , SnapshotRetention , SnapshotSummaryCollector , Struct , StructType ,
30
+ Summary , update_snapshot_summaries,
31
31
} ;
32
32
use crate :: table:: Table ;
33
33
use crate :: transaction:: ActionCommit ;
@@ -177,7 +177,11 @@ impl SnapshotProducer {
177
177
snapshot_id
178
178
}
179
179
180
- fn new_manifest_output ( & mut self , table : & Table ) -> Result < OutputFile > {
180
+ fn new_manifest_writer (
181
+ & mut self ,
182
+ content : ManifestContentType ,
183
+ table : & Table ,
184
+ ) -> Result < ManifestWriter > {
181
185
let new_manifest_path = format ! (
182
186
"{}/{}/{}-m{}.{}" ,
183
187
table. metadata( ) . location( ) ,
@@ -186,7 +190,22 @@ impl SnapshotProducer {
186
190
self . manifest_counter. next( ) . unwrap( ) ,
187
191
DataFileFormat :: Avro
188
192
) ;
189
- table. file_io ( ) . new_output ( new_manifest_path)
193
+ let output_file = table. file_io ( ) . new_output ( new_manifest_path) ?;
194
+ let builder = ManifestWriterBuilder :: new (
195
+ output_file,
196
+ Some ( self . snapshot_id ) ,
197
+ self . key_metadata . clone ( ) ,
198
+ table. metadata ( ) . current_schema ( ) . clone ( ) ,
199
+ table. metadata ( ) . default_partition_spec ( ) . as_ref ( ) . clone ( ) ,
200
+ ) ;
201
+ if table. metadata ( ) . format_version ( ) == FormatVersion :: V1 {
202
+ Ok ( builder. build_v1 ( ) )
203
+ } else {
204
+ match content {
205
+ ManifestContentType :: Data => Ok ( builder. build_v2_data ( ) ) ,
206
+ ManifestContentType :: Deletes => Ok ( builder. build_v2_deletes ( ) ) ,
207
+ }
208
+ }
190
209
}
191
210
192
211
// Check if the partition value is compatible with the partition type.
@@ -244,20 +263,7 @@ impl SnapshotProducer {
244
263
builder. build ( )
245
264
}
246
265
} ) ;
247
- let mut writer = {
248
- let builder = ManifestWriterBuilder :: new (
249
- self . new_manifest_output ( table) ?,
250
- Some ( self . snapshot_id ) ,
251
- self . key_metadata . clone ( ) ,
252
- table. metadata ( ) . current_schema ( ) . clone ( ) ,
253
- table. metadata ( ) . default_partition_spec ( ) . as_ref ( ) . clone ( ) ,
254
- ) ;
255
- if table. metadata ( ) . format_version ( ) == FormatVersion :: V1 {
256
- builder. build_v1 ( )
257
- } else {
258
- builder. build_v2_data ( )
259
- }
260
- } ;
266
+ let mut writer = self . new_manifest_writer ( ManifestContentType :: Data , table) ?;
261
267
for entry in manifest_entries {
262
268
writer. add_entry ( entry) ?;
263
269
}
0 commit comments