From f30b4a53522c62926fff8022b5fefc138683ec75 Mon Sep 17 00:00:00 2001 From: jayzhan211 Date: Thu, 18 Jul 2024 19:28:40 +0800 Subject: [PATCH] rm clone Signed-off-by: jayzhan211 --- datafusion/optimizer/src/push_down_filter.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs index 20e2ac07dffd..5174e7b35872 100644 --- a/datafusion/optimizer/src/push_down_filter.rs +++ b/datafusion/optimizer/src/push_down_filter.rs @@ -1020,7 +1020,7 @@ impl OptimizerRule for PushDownFilter { /// ``` fn rewrite_projection( predicates: Vec, - projection: Projection, + mut projection: Projection, ) -> Result<(Transformed, Option)> { // 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. @@ -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), )) }