Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions parquet/src/arrow/arrow_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,15 @@ impl<T: ChunkReader + 'static> ParquetRecordBatchReaderBuilder<T> {
let (row_groups, selection) = row_group_plan.into_global()?;

let row_groups = row_groups.unwrap_or_else(|| (0..metadata.num_row_groups()).collect());
if let Some(idx) = row_groups
.iter()
.find(|idx| **idx >= metadata.num_row_groups())
{
return Err(general_err!(
"Row group index {idx} out of bounds for file with {} row groups",
metadata.num_row_groups()
));
}

let reader = ReaderRowGroups {
reader: Arc::new(input.0),
Expand Down
17 changes: 17 additions & 0 deletions parquet/src/arrow/arrow_reader/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,23 @@ fn create_test_selection(
(vec.into(), selected_count)
}

#[test]
fn test_row_group_index_out_of_bounds() {
let testdata = arrow::util::test_util::parquet_test_data();
let path = format!("{testdata}/alltypes_plain.parquet");
let test_file = File::open(path).unwrap();

let err = ParquetRecordBatchReaderBuilder::try_new(test_file)
.unwrap()
.with_row_groups(vec![0, 1])
.build()
.unwrap_err();
assert_eq!(
err.to_string(),
"Parquet error: Row group index 1 out of bounds for file with 1 row groups"
);
}

#[test]
fn test_batch_size_overallocate() {
let testdata = arrow::util::test_util::parquet_test_data();
Expand Down