Skip to content

Commit

Permalink
Parquet limit pushdown (apache#5404)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Feb 27, 2023
1 parent c0defeb commit f9dc332
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions datafusion/core/src/physical_plan/file_format/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ impl ExecutionPlan for ParquetExec {
partition_index,
projection: Arc::from(projection),
batch_size: ctx.session_config().batch_size(),
limit: self.base_config.limit,
predicate: self.predicate.clone(),
pruning_predicate: self.pruning_predicate.clone(),
page_pruning_predicate: self.page_pruning_predicate.clone(),
Expand Down Expand Up @@ -460,6 +461,7 @@ struct ParquetOpener {
partition_index: usize,
projection: Arc<[usize]>,
batch_size: usize,
limit: Option<usize>,
predicate: Option<Arc<Expr>>,
pruning_predicate: Option<Arc<PruningPredicate>>,
page_pruning_predicate: Option<Arc<PagePruningPredicate>>,
Expand Down Expand Up @@ -500,6 +502,7 @@ impl FileOpener for ParquetOpener {
let reorder_predicates = self.reorder_filters;
let pushdown_filters = self.pushdown_filters;
let enable_page_index = self.enable_page_index;
let limit = self.limit;

Ok(Box::pin(async move {
let options = ArrowReaderOptions::new().with_page_index(enable_page_index);
Expand Down Expand Up @@ -562,6 +565,10 @@ impl FileOpener for ParquetOpener {
}
}

if let Some(limit) = self.limit {
builder = builder.with_limit(limit)
}

let stream = builder
.with_projection(mask)
.with_batch_size(batch_size)
Expand Down

0 comments on commit f9dc332

Please sign in to comment.