linyiru opened a new issue, #12497:
URL: https://github.com/apache/arrow-rs/issues/12497

   ### Describe the bug
   
   `ParquetRecordBatchReaderBuilder::with_row_groups(...)` followed by 
`build()` panics when an index is not a row group of the file. `build()` 
returns a `Result`, and the push decoder already reports this case as an error 
(`Row group index 2 out of bounds for file with 2 row groups`).
   
   ### To Reproduce
   
   ```rust
   use std::fs::File;
   
   use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder;
   
   fn main() {
       // one row group
       let path = "parquet-testing/data/alltypes_plain.parquet";
       let result = 
ParquetRecordBatchReaderBuilder::try_new(File::open(path).unwrap())
           .unwrap()
           .with_row_groups(vec![1])
           .build();
       println!("{:?}", result.map(|_| ()));
   }
   ```
   
   On 60.2.0 and on main (d470f2d54):
   
   ```
   thread 'main' panicked at parquet/src/arrow/arrow_reader/mod.rs:1436:22:
   index out of bounds: the len is 1 but the index is 1
   ```
   
   ### Expected behavior
   
   `build()` returns `Err(General("Row group index 1 out of bounds for file 
with 1 row groups"))`, the message the push decoder and 
`ParquetMetaData::row_group_num_rows` use.
   
   ### Additional context
   
   The panic is in `ReaderRowGroups::num_rows`, which indexes the row group 
metadata with the caller's list.
   
   `ProjectionMask::leaves` and `ProjectionMask::roots` also panic on an 
out-of-range index (`parquet/src/arrow/mod.rs:303`, `:317`). They return 
`Self`, so that is a separate question (a `# Panics` section, or ignoring the 
index); not part of this issue.
   
   This report was prepared with AI assistance (Claude Code). The reproduction 
was run against 60.2.0 and main.
   
   ### Willingness to contribute
   
   I plan to contribute a fix for this bug independently
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to