Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent "index out of range for slice" error in parquet reader #15021

Merged
merged 2 commits into from
Mar 14, 2024
Merged

fix: Prevent "index out of range for slice" error in parquet reader #15021

merged 2 commits into from
Mar 14, 2024

Conversation

mkysylov
Copy link
Contributor

@mkysylov mkysylov commented Mar 12, 2024

Fixes #15020

@mkysylov mkysylov changed the title Fix "index out of range for slice" error in parquet reader. fix: Prevent "index out of range for slice" error in parquet reader Mar 12, 2024
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Mar 12, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 81.01%. Comparing base (f2a18cd) to head (893fe50).
Report is 11 commits behind head on main.

Files Patch % Lines
crates/polars-io/src/parquet/read_impl.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15021      +/-   ##
==========================================
+ Coverage   80.97%   81.01%   +0.03%     
==========================================
  Files        1333     1338       +5     
  Lines      173189   173602     +413     
  Branches     2460     2460              
==========================================
+ Hits       140240   140641     +401     
- Misses      32479    32493      +14     
+ Partials      470      468       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -608,6 +608,8 @@ impl BatchedParquetReader {
if self.limit == 0 && self.has_returned {
return if self.chunks_fifo.is_empty() {
Ok(None)
} else if self.chunks_fifo.len() < n {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the extra else if and write self.chunk_fifo.drain(..std::cmp::min(n, self.chunk_fifo.len()))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for suggestion!
I moved min into a separate line for slightly better readability.

@mkysylov mkysylov requested a review from ritchie46 March 13, 2024 20:00
Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ritchie46 ritchie46 merged commit f6499b8 into pola-rs:main Mar 14, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parquet reader crashes with "range end index 16 out of range for slice" error
2 participants