@@ -254,7 +254,7 @@ impl<'a> SnapshotProducer<'a> {
254
254
if added_data_files. is_empty ( ) {
255
255
return Err ( Error :: new (
256
256
ErrorKind :: PreconditionFailed ,
257
- "No added data files found when write a manifest file" ,
257
+ "No added data files found when write an added manifest file" ,
258
258
) ) ;
259
259
}
260
260
@@ -284,13 +284,30 @@ impl<'a> SnapshotProducer<'a> {
284
284
snapshot_produce_operation : & OP ,
285
285
manifest_process : & MP ,
286
286
) -> Result < Vec < ManifestFile > > {
287
- let added_manifest = self . write_added_manifest ( ) . await ?;
287
+ // Assert current snapshot producer contains new content to add to new snapshot.
288
+ //
289
+ // TODO: Allowing snapshot property setup with no added data files is a workaround.
290
+ // We should clean it up after all necessary actions are supported.
291
+ // For details, please refer to https://github.com/apache/iceberg-rust/issues/1548
292
+ if self . added_data_files . is_empty ( ) && self . snapshot_properties . is_empty ( ) {
293
+ return Err ( Error :: new (
294
+ ErrorKind :: PreconditionFailed ,
295
+ "No added data files or added snapshot properties found when write a manifest file" ,
296
+ ) ) ;
297
+ }
298
+
288
299
let existing_manifests = snapshot_produce_operation. existing_manifest ( self ) . await ?;
300
+ let mut manifest_files = existing_manifests;
301
+
302
+ // Process added entries.
303
+ if !self . added_data_files . is_empty ( ) {
304
+ let added_manifest = self . write_added_manifest ( ) . await ?;
305
+ manifest_files. push ( added_manifest) ;
306
+ }
307
+
289
308
// # TODO
290
309
// Support process delete entries.
291
310
292
- let mut manifest_files = vec ! [ added_manifest] ;
293
- manifest_files. extend ( existing_manifests) ;
294
311
let manifest_files = manifest_process. process_manifests ( self , manifest_files) ;
295
312
Ok ( manifest_files)
296
313
}
0 commit comments