Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions datafusion/optimizer/src/optimize_projections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@ fn merge_consecutive_projections(proj: Projection) -> Result<Transformed<Project
return Projection::try_new_with_schema(expr, input, schema).map(Transformed::no);
};

// A fast path: if the previous projection is same as the current projection
// we can directly remove the current projection and return child projection.
if prev_projection.expr == expr {
return Projection::try_new_with_schema(
expr,
Arc::clone(&prev_projection.input),
schema,
)
.map(Transformed::yes);
}

// Count usages (referrals) of each projection expression in its input fields:
let mut column_referral_map = HashMap::<&Column, usize>::new();
expr.iter()
Expand Down