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

refactor: move describe to IR instead of DSL #16191

Merged
merged 3 commits into from
May 14, 2024
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
14 changes: 12 additions & 2 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl LazyFrame {
self.logical_plan.describe_tree_format()
}

fn optimized_plan(&self) -> PolarsResult<DslPlan> {
fn optimized_plan_ir(&self) -> PolarsResult<IRPlan> {
let mut expr_arena = Arena::with_capacity(64);
let mut lp_arena = Arena::with_capacity(64);
let lp_top = self.clone().optimize_with_scratch(
Expand All @@ -224,14 +224,24 @@ impl LazyFrame {
&mut vec![],
true,
)?;

Ok(IRPlan::new(lp_top, lp_arena, expr_arena))
}

fn optimized_plan(&self) -> PolarsResult<DslPlan> {
let IRPlan {
lp_top,
mut lp_arena,
expr_arena,
} = self.optimized_plan_ir()?;
Ok(node_to_lp(lp_top, &expr_arena, &mut lp_arena))
}

/// Return a String describing the optimized logical plan.
///
/// Returns `Err` if optimizing the logical plan fails.
pub fn describe_optimized_plan(&self) -> PolarsResult<String> {
Ok(self.optimized_plan()?.describe())
Ok(self.optimized_plan_ir()?.describe())
}

/// Return a String describing the optimized logical plan in tree format.
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-plan/src/logical_plan/aexpr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl From<AAggExpr> for GroupByMethod {
}
}

// AExpr representation of Nodes which are allocated in an Arena
/// IR expression node that is allocated in an [`Arena`][polars_utils::arena::Arena].
#[derive(Clone, Debug, Default)]
pub enum AExpr {
Explode(Node),
Expand Down
Loading