From 8100a9f1a3e0df2f0b9d26016b102f6eb9dbef36 Mon Sep 17 00:00:00 2001 From: hezheyu Date: Fri, 1 Sep 2023 11:49:12 +0800 Subject: [PATCH] fix: avoid panic if offset index not exists. --- parquet/src/arrow/arrow_reader/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parquet/src/arrow/arrow_reader/mod.rs b/parquet/src/arrow/arrow_reader/mod.rs index 5f95a8664b4b..0912275d5354 100644 --- a/parquet/src/arrow/arrow_reader/mod.rs +++ b/parquet/src/arrow/arrow_reader/mod.rs @@ -480,7 +480,10 @@ impl Iterator for ReaderPageIterator { let rg = self.metadata.row_group(rg_idx); let meta = rg.column(self.column_idx); let offset_index = self.metadata.offset_index(); - let page_locations = offset_index.map(|i| i[rg_idx][self.column_idx].clone()); + // `offset_index` may not exist and the inner `Vec` will be empty. + let page_locations = offset_index + .filter(|i| !i[rg_idx].is_empty()) + .map(|i| i[rg_idx][self.column_idx].clone()); let total_rows = rg.num_rows() as usize; let reader = self.reader.clone();