Skip to content

Commit

Permalink
[BLAZE-803] Support statistics of ExecutionPlan for LimitExec
Browse files Browse the repository at this point in the history
  • Loading branch information
SteNicholas committed Jan 30, 2025
1 parent f6452a7 commit 305495f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions native-engine/datafusion-ext-plans/src/limit_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ impl ExecutionPlan for LimitExec {
}

fn statistics(&self) -> Result<Statistics> {
todo!()
Statistics::with_fetch(
self.input.statistics()?,
self.schema(),
Some(self.limit as usize),
0,
1,
)
}
}

Expand Down Expand Up @@ -130,7 +136,7 @@ mod test {
};
use datafusion::{
assert_batches_eq,
common::Result,
common::{stats::Precision, Result},
physical_plan::{common, memory::MemoryExec, ExecutionPlan},
prelude::SessionContext,
};
Expand Down Expand Up @@ -182,6 +188,7 @@ mod test {
let task_ctx = session_ctx.task_ctx();
let output = limit_exec.execute(0, task_ctx).unwrap();
let batches = common::collect(output).await?;
let row_count = limit_exec.statistics()?.num_rows;

let expected = vec![
"+---+---+---+",
Expand All @@ -192,6 +199,7 @@ mod test {
"+---+---+---+",
];
assert_batches_eq!(expected, &batches);
assert_eq!(row_count, Precision::Exact(2));
Ok(())
}
}

0 comments on commit 305495f

Please sign in to comment.