File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
datafusion/optimizer/src/optimize_projections Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -455,6 +455,17 @@ fn merge_consecutive_projections(proj: Projection) -> Result<Transformed<Project
455455 return Projection :: try_new_with_schema ( expr, input, schema) . map ( Transformed :: no) ;
456456 } ;
457457
458+ // A fast path: if the previous projection is same as the current projection
459+ // we can directly remove the current projection and return child projection.
460+ if prev_projection. expr == expr {
461+ return Projection :: try_new_with_schema (
462+ expr,
463+ Arc :: clone ( & prev_projection. input ) ,
464+ schema,
465+ )
466+ . map ( Transformed :: yes) ;
467+ }
468+
458469 // Count usages (referrals) of each projection expression in its input fields:
459470 let mut column_referral_map = HashMap :: < & Column , usize > :: new ( ) ;
460471 expr. iter ( )
You can’t perform that action at this time.
0 commit comments