Skip to content

Commit

Permalink
feat: Show warning if expressions are very deep (#16233)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored May 15, 2024
1 parent 15f6b36 commit 6716651
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 84 deletions.
4 changes: 2 additions & 2 deletions crates/polars-lazy/src/dsl/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use polars_core::prelude::*;
use rayon::prelude::*;

use super::*;
use crate::physical_plan::planner::create_physical_expr;
use crate::physical_plan::planner::{create_physical_expr, ExpressionConversionState};
use crate::physical_plan::state::ExecutionState;
use crate::prelude::*;

Expand Down Expand Up @@ -61,7 +61,7 @@ pub trait ExprEvalExtension: IntoExpr + Sized {
Context::Default,
&arena,
None,
&mut Default::default(),
&mut ExpressionConversionState::new(true, 0),
)?;

let state = ExecutionState::new();
Expand Down
6 changes: 4 additions & 2 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use polars_plan::global::FETCH_ROWS;
use smartstring::alias::String as SmartString;

use crate::physical_plan::executors::Executor;
use crate::physical_plan::planner::{create_physical_expr, create_physical_plan};
use crate::physical_plan::planner::{
create_physical_expr, create_physical_plan, ExpressionConversionState,
};
use crate::physical_plan::state::ExecutionState;
#[cfg(feature = "streaming")]
use crate::physical_plan::streaming::insert_streaming_nodes;
Expand Down Expand Up @@ -571,7 +573,7 @@ impl LazyFrame {
Context::Default,
expr_arena,
None,
&mut Default::default(),
&mut ExpressionConversionState::new(true, 0),
)
.ok()?;
let io_expr = phys_expr_to_io_expr(phys_expr);
Expand Down
10 changes: 8 additions & 2 deletions crates/polars-lazy/src/physical_plan/exotic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use polars_core::prelude::*;

use crate::physical_plan::planner::create_physical_expr;
use crate::physical_plan::planner::{create_physical_expr, ExpressionConversionState};
use crate::prelude::*;

#[cfg(feature = "pivot")]
Expand Down Expand Up @@ -34,5 +34,11 @@ pub(crate) fn prepare_expression_for_context(
let lp = lp_arena.get(optimized);
let aexpr = lp.get_exprs().pop().unwrap();

create_physical_expr(&aexpr, ctxt, &expr_arena, None, &mut Default::default())
create_physical_expr(
&aexpr,
ctxt,
&expr_arena,
None,
&mut ExpressionConversionState::new(true, 0),
)
}
Loading

0 comments on commit 6716651

Please sign in to comment.