Skip to content

Commit 02ca330

Browse files
committed
ignore fields in manifest that don't exist
1 parent 12c8fcc commit 02ca330

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

crates/iceberg/src/transaction/rewrite_files.rs

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -169,31 +169,21 @@ impl TransactionAction for RewriteFilesAction {
169169
}
170170
}
171171

172-
fn copy_with_deleted_status(entry: &ManifestEntryRef) -> Result<ManifestEntry> {
173-
// todo should we fail on missing properties or should we ignore them when they don't exist?
174-
let builder = ManifestEntry::builder()
172+
fn copy_with_deleted_status(entry: &ManifestEntry) -> Result<ManifestEntry> {
173+
let mut builder = ManifestEntry::builder()
175174
.status(ManifestStatus::Deleted)
176-
.snapshot_id(entry.snapshot_id().ok_or_else(|| {
177-
Error::new(
178-
ErrorKind::DataInvalid,
179-
format!(
180-
"Missing snapshot_id for entry with file path: {}",
181-
entry.file_path()
182-
),
183-
)
184-
})?)
185-
.sequence_number(entry.sequence_number().ok_or_else(|| {
186-
Error::new(
187-
ErrorKind::DataInvalid,
188-
format!(
189-
"Missing sequence_number for entry with file path: {}",
190-
entry.file_path()
191-
),
192-
)
193-
})?)
194-
// todo copy file seq no as well
195175
.data_file(entry.data_file().clone());
196176

177+
if let Some(snapshot_id) = entry.snapshot_id() {
178+
builder = builder.snapshot_id(snapshot_id);
179+
}
180+
181+
if let Some(sequence_number) = entry.sequence_number() {
182+
builder = builder.sequence_number(sequence_number);
183+
}
184+
185+
// todo copy file seq no as well
186+
197187
Ok(builder.build())
198188
}
199189

@@ -271,7 +261,7 @@ impl SnapshotProduceOperation for RewriteFilesOperation {
271261
.iter()
272262
.any(|f| f.file_path == entry.data_file().file_path)
273263
{
274-
delete_entries.push(copy_with_deleted_status(entry)?)
264+
delete_entries.push(copy_with_deleted_status(entry.as_ref())?)
275265
}
276266
}
277267
DataContentType::PositionDeletes | DataContentType::EqualityDeletes => {
@@ -280,7 +270,7 @@ impl SnapshotProduceOperation for RewriteFilesOperation {
280270
.iter()
281271
.any(|f| f.file_path == entry.data_file().file_path)
282272
{
283-
delete_entries.push(copy_with_deleted_status(entry)?)
273+
delete_entries.push(copy_with_deleted_status(entry.as_ref())?)
284274
}
285275
}
286276
}

0 commit comments

Comments
 (0)