joroKr21 commented on code in PR #21668:
URL: https://github.com/apache/datafusion/pull/21668#discussion_r3264639391


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -1441,42 +1355,65 @@ where
 
 /// replaces columns by its name on the projection.
 pub fn replace_cols_by_name(
-    e: Expr,
-    replace_map: &HashMap<String, Expr>,
+    expr: Expr,
+    replace_map: &HashMap<String, impl AsRef<Expr>>,
 ) -> Result<Expr> {
-    e.transform_up(|expr| {
-        Ok(if let Expr::Column(c) = &expr {
-            match replace_map.get(&c.flat_name()) {
-                Some(new_c) => Transformed::yes(new_c.clone()),
-                None => Transformed::no(expr),
-            }
+    expr.transform_up(|expr| {
+        if let Expr::Column(col) = &expr
+            && let Some(new_expr) = replace_map.get(&col.flat_name())
+        {
+            Ok(Transformed::yes(new_expr.as_ref().clone()))
         } else {
-            Transformed::no(expr)
-        })
+            Ok(Transformed::no(expr))
+        }
     })
     .data()
 }
 
+/// Unalias expression reference.
+fn unalias(expr: &Expr) -> &Expr {

Review Comment:
   That one takes an owned expression so it would require a clone



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to