Skip to content

Commit

Permalink
Trim parquet row selection (#2705)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Sep 24, 2022
1 parent dc62e40 commit 7c8080c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parquet/src/arrow/arrow_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl ParquetRecordBatchReader {
batch_size,
array_reader,
schema: Arc::new(schema),
selection: selection.map(Into::into),
selection: selection.map(|s| s.trim().into()),
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions parquet/src/arrow/arrow_reader/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ impl RowSelection {
pub fn selects_any(&self) -> bool {
self.selectors.iter().any(|x| !x.skip)
}

/// Trims this [`RowSelection`] removing any trailing skips
pub(crate) fn trim(mut self) -> Self {
while self.selectors.last().map(|x| x.skip).unwrap_or(false) {
self.selectors.pop();
}
self
}
}

impl From<Vec<RowSelector>> for RowSelection {
Expand Down

0 comments on commit 7c8080c

Please sign in to comment.