Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Add PyDataFrame.explain (#36)
Browse files Browse the repository at this point in the history
* Add PyDataFrame.explain

* fix indent

* print results in explain rather than returning the data
  • Loading branch information
andygrove authored Mar 10, 2022
1 parent 7dd6807 commit 3f2bd29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions datafusion/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,11 @@ def test_struct_select(struct_df):

assert result.column(0) == pa.array([5, 7, 9])
assert result.column(1) == pa.array([-3, -3, -3])


def test_explain(df):
df = df.select(
column("a") + column("b"),
column("a") - column("b"),
)
df.explain()
8 changes: 8 additions & 0 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,12 @@ impl PyDataFrame {
.join(right.df, join_type, &join_keys.0, &join_keys.1)?;
Ok(Self::new(df))
}

/// Print the query plan
#[args(verbose = false, analyze = false)]
fn explain(&self, py: Python, verbose: bool, analyze: bool) -> PyResult<()> {
let df = self.df.explain(verbose, analyze)?;
let batches = wait_for_future(py, df.collect())?;
Ok(pretty::print_batches(&batches)?)
}
}

0 comments on commit 3f2bd29

Please sign in to comment.