File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
datafusion/optimizer/src/optimize_projections Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -786,8 +786,12 @@ fn rewrite_projection_given_requirements(
786786/// - input schema of the projection, output schema of the projection are same, and
787787/// - all projection expressions are either Column or Literal
788788fn 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+ }
789793 let proj_schema = projection_schema ( input, proj_exprs) ?;
790- Ok ( & proj_schema == input. schema ( ) && proj_exprs . iter ( ) . all ( is_expr_trivial ) )
794+ Ok ( & proj_schema == input. schema ( ) )
791795}
792796
793797#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments