Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Remove clone in PushDownFilter #11532

Merged
merged 1 commit into from
Jul 18, 2024
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
8 changes: 5 additions & 3 deletions datafusion/optimizer/src/push_down_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ impl OptimizerRule for PushDownFilter {
/// ```
fn rewrite_projection(
predicates: Vec<Expr>,
projection: Projection,
mut projection: Projection,
) -> Result<(Transformed<LogicalPlan>, Option<Expr>)> {
// A projection is filter-commutable if it do not contain volatile predicates or contain volatile
// predicates that are not used in the filter. However, we should re-writes all predicate expressions.
Expand Down Expand Up @@ -1053,11 +1053,13 @@ fn rewrite_projection(
// E.g. in `Filter: b\n Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
let new_filter = LogicalPlan::Filter(Filter::try_new(
replace_cols_by_name(expr, &non_volatile_map)?,
Arc::clone(&projection.input),
std::mem::take(&mut projection.input),
)?);

projection.input = Arc::new(new_filter);

Ok((
insert_below(LogicalPlan::Projection(projection), new_filter)?,
Transformed::yes(LogicalPlan::Projection(projection)),
conjunction(keep_predicates),
))
}
Expand Down