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

Add partition_count property to ExecutionPlan. #346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions datafusion/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ def test_execution_plan(aggregate_df):

assert expected == plan.display()

# Check the number of partitions is as expected.
assert type(plan.partition_count) is int

expected = (
"ProjectionExec: expr=[c1@0 as c1, SUM(test.c2)@1 as SUM(test.c2)]\n"
" Aggregate: groupBy=[[test.c1]], aggr=[[SUM(test.c2)]]\n"
Expand Down
2 changes: 1 addition & 1 deletion examples/substrait.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
ctx = SessionContext()

# Register table with context
ctx.register_parquet(
ctx.register_csv(
"aggregate_test_data", "./testing/data/csv/aggregate_test_100.csv"
)

Expand Down
5 changes: 5 additions & 0 deletions src/physical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ impl PyExecutionPlan {
let d = displayable(self.plan.as_ref());
format!("{}", d.indent())
}

#[getter]
pub fn partition_count(&self) -> usize {
self.plan.output_partitioning().partition_count()
}
}

impl From<PyExecutionPlan> for Arc<dyn ExecutionPlan> {
Expand Down