diff --git a/crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs b/crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs index c5073f8accd0..d6f118dfd87a 100644 --- a/crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs +++ b/crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs @@ -30,7 +30,7 @@ use crate::utils::aexpr_to_leaf_names; #[derive(Default, Copy, Clone)] struct ProjectionCopyState { projections_seen: usize, - count_star: bool, + is_count_star: bool, } #[derive(Clone, Default)] @@ -58,7 +58,7 @@ impl ProjectionContext { fn has_pushed_down(&self) -> bool { // count star also acts like a pushdown as we will select a single column at the source // when there were no other projections. - !self.acc_projections.is_empty() || self.inner.count_star + !self.acc_projections.is_empty() || self.inner.is_count_star } fn process_count_star_at_scan(&mut self, schema: &Schema, expr_arena: &mut Arena) { diff --git a/crates/polars-plan/src/plans/optimizer/projection_pushdown/projection.rs b/crates/polars-plan/src/plans/optimizer/projection_pushdown/projection.rs index 6be0c26b860d..582241c23b29 100644 --- a/crates/polars-plan/src/plans/optimizer/projection_pushdown/projection.rs +++ b/crates/polars-plan/src/plans/optimizer/projection_pushdown/projection.rs @@ -22,65 +22,10 @@ pub(super) fn process_projection( // as there would be no projections and we would read // the whole file while we only want the count if exprs.len() == 1 && is_count(exprs[0].node(), expr_arena) { - //let input_schema = lp_arena.get(input).schema(lp_arena); - //let expr = exprs[0].node(); - //let expr = if input_schema.is_empty() { - // // If the input schema is empty, we should just project - // // ourselves - // exprs[0].node() - //} else { - // // Select the last column projection. - // let (last_name, _) = input_schema.try_get_at_index(input_schema.len() - 1)?; - // - // let name = match lp_arena.get(input) { - // IR::Select { expr: exprs, .. } | IR::HStack { exprs, .. } => (|| { - // for e in exprs { - // if !e.is_scalar(expr_arena) { - // return e.output_name(); - // } - // } - // - // last_name - // })(), - // - // IR::Scan { - // file_info, - // output_schema, - // .. - // } => { - // let schema = output_schema.as_ref().unwrap_or(&file_info.schema); - // // NOTE: the first can be the inserted index column, so that might not work - // let (last_name, _) = schema.try_get_at_index(schema.len() - 1)?; - // last_name - // }, - // - // IR::DataFrameScan { - // schema, - // output_schema, - // .. - // } => { - // // NOTE: the first can be the inserted index column, so that might not work - // let schema = output_schema.as_ref().unwrap_or(schema); - // let (last_name, _) = schema.try_get_at_index(schema.len() - 1)?; - // last_name - // }, - // - // _ => last_name, - // }; - // - // expr_arena.add(AExpr::Column(name.clone())) - //}; - // Clear all accumulated projections since we only project a single column from this level. ctx.acc_projections.clear(); ctx.projected_names.clear(); - ctx.inner.count_star = true; - //add_expr_to_accumulated( - // expr, - // &mut ctx.acc_projections, - // &mut ctx.projected_names, - // expr_arena, - //); + ctx.inner.is_count_star = true; local_projection.push(exprs.pop().unwrap()); proj_pd.is_count_star = true; } else {