We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66a7423 commit 6ffed55Copy full SHA for 6ffed55
datafusion/optimizer/src/optimize_projections/mod.rs
@@ -786,8 +786,12 @@ fn rewrite_projection_given_requirements(
786
/// - input schema of the projection, output schema of the projection are same, and
787
/// - all projection expressions are either Column or Literal
788
fn is_projection_unnecessary(input: &LogicalPlan, proj_exprs: &[Expr]) -> Result<bool> {
789
+ // First check if all expressions are trivial (cheaper operation than `projection_schema`)
790
+ if !proj_exprs.iter().all(is_expr_trivial) {
791
+ return Ok(false);
792
+ }
793
let proj_schema = projection_schema(input, proj_exprs)?;
- Ok(&proj_schema == input.schema() && proj_exprs.iter().all(is_expr_trivial))
794
+ Ok(&proj_schema == input.schema())
795
}
796
797
#[cfg(test)]
0 commit comments