Skip to content

Commit

Permalink
fix: Don't vertically parallelize literal select (#19295)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Oct 18, 2024
1 parent f6b56c9 commit dae6cd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions crates/polars-expr/src/expressions/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl PhysicalExpr for AliasExpr {
))
}

fn is_literal(&self) -> bool {
self.physical_expr.is_literal()
}

fn is_scalar(&self) -> bool {
self.physical_expr.is_scalar()
}
Expand Down
10 changes: 7 additions & 3 deletions crates/polars-mem-engine/src/planner/lp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,20 @@ fn create_physical_plan_impl(
POOL.current_num_threads() > expr.len(),
state.expr_depth,
);

let streamable =
options.should_broadcast && all_streamable(&expr, expr_arena, Context::Default);
let phys_expr = create_physical_expressions_from_irs(
&expr,
Context::Default,
expr_arena,
&input_schema,
&mut state,
)?;

let streamable = options.should_broadcast && all_streamable(&expr, expr_arena, Context::Default)
// If all columns are literal we would get a 1 row per thread.
&& !phys_expr.iter().all(|p| {
p.is_literal()
});

Ok(Box::new(executors::ProjectionExec {
input,
expr: phys_expr,
Expand Down

0 comments on commit dae6cd9

Please sign in to comment.