From 1611ca1efd8fd0ccd0e19eec797e9a2944a31748 Mon Sep 17 00:00:00 2001 From: berkaysynnada Date: Tue, 30 Apr 2024 13:08:33 +0300 Subject: [PATCH] Update optimize_projections.rs --- .../core/src/physical_optimizer/optimize_projections.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datafusion/core/src/physical_optimizer/optimize_projections.rs b/datafusion/core/src/physical_optimizer/optimize_projections.rs index eda1716b8141..688d7f57f17f 100644 --- a/datafusion/core/src/physical_optimizer/optimize_projections.rs +++ b/datafusion/core/src/physical_optimizer/optimize_projections.rs @@ -459,7 +459,9 @@ impl ProjectionOptimizer { let Some(projection) = self.plan.as_any().downcast_ref::() else { return Ok(Transformed::no(self)); }; - // If the projection does not narrow the schema, we should not try to push it down: + // If the projection does not narrow the schema or it does some calculations, + // we should not try to push it down to have less computation during execution. + // (Making any computation dominates the existance of column elimination) if projection.expr().len() >= projection.input().schema().fields().len() || !projection.expr().iter().all(|(expr, _)| { expr.as_any().downcast_ref::().is_some()