Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/iceberg/src/arrow/caching_delete_file_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ impl CachingDeleteFileLoader {
));
};

if pos < 0 {
return Err(Error::new(
ErrorKind::DataInvalid,
format!("negative position in delete file: {pos}"),
));
}

result
.entry(file_path.to_string())
.or_default()
Expand Down Expand Up @@ -768,6 +775,22 @@ mod tests {
assert!(result.is_none()); // no pos dels for file 3
}

#[tokio::test]
async fn test_parse_positional_deletes_rejects_negative_positions() {
let schema = crate::arrow::delete_filter::tests::create_pos_del_schema();
let file_path_col = Arc::new(StringArray::from_iter_values(vec!["data.parquet"]));
let pos_col = Arc::new(Int64Array::from_iter_values(vec![-1i64]));
let batch = RecordBatch::try_new(schema, vec![file_path_col, pos_col]).unwrap();
let stream = futures::stream::iter(vec![Ok(batch)]).boxed();

let err = CachingDeleteFileLoader::parse_positional_deletes_record_batch_stream(stream)
.await
.unwrap_err();

assert_eq!(err.kind(), ErrorKind::DataInvalid);
assert!(err.message().contains("negative position"));
}

/// Verifies that evolve_schema on partial-schema equality deletes works correctly
/// when only equality_ids columns are evolved, not all table columns.
///
Expand Down
Loading