You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "RinChanNOWWW (via GitHub)" <gi...@apache.org> on 2023/09/01 03:57:14 UTC

[GitHub] [arrow-rs] RinChanNOWWW opened a new pull request, #4761: fix: avoid panic if offset index not exists.

RinChanNOWWW opened a new pull request, #4761:
URL: https://github.com/apache/arrow-rs/pull/4761

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
   
   `index_reader::read_pages_locations` will return an empty `Vec<PageLocation>` if there isn't an offset index:
   
   ```rust
   pub fn read_pages_locations<R: ChunkReader>(
       reader: &R,
       chunks: &[ColumnChunkMetaData],
   ) -> Result<Vec<Vec<PageLocation>>, ParquetError> {
       let fetch = chunks
           .iter()
           .fold(None, |range, c| acc_range(range, c.offset_index_range()));
   
       let fetch = match fetch {
           Some(r) => r,
           None => return Ok(vec![]),
       };
   
       let bytes = reader.get_bytes(fetch.start as _, fetch.end - fetch.start)?;
       let get = |r: Range<usize>| &bytes[(r.start - fetch.start)..(r.end - fetch.start)];
   
       chunks
           .iter()
           .map(|c| match c.offset_index_range() {
               Some(r) => decode_offset_index(get(r)),
               None => Err(general_err!("missing offset index")),
           })
           .collect()
   }
   ```
   
   However, it will be set as a `Some(ParquetOffsetIndex)` to `ParquetMetaData`'s `offset_index`.
   
   When we read data by a `ChunkReader`, we will get page locations of a column by `i[rg_idx][self.column_idx]`. But `i[rg_idx]` maybe empty and it will lead to panic!
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   Check if `offset_index` is empty before getting `PageLocations` from it.
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   No.
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] RinChanNOWWW commented on pull request #4761: fix: avoid panic if offset index not exists.

Posted by "RinChanNOWWW (via GitHub)" <gi...@apache.org>.
RinChanNOWWW commented on PR #4761:
URL: https://github.com/apache/arrow-rs/pull/4761#issuecomment-1703993938

   > Could we get a test for this please?
   
   Done. PTAL.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on pull request #4761: fix: avoid panic if offset index not exists.

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #4761:
URL: https://github.com/apache/arrow-rs/pull/4761#issuecomment-1702580454

   Could we get a test for this please?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on pull request #4761: fix: avoid panic if offset index not exists.

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #4761:
URL: https://github.com/apache/arrow-rs/pull/4761#issuecomment-1705101083

   Thank you


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold merged pull request #4761: fix: avoid panic if offset index not exists.

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #4761:
URL: https://github.com/apache/arrow-rs/pull/4761


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org