xudong963 commented on code in PR #15906:
URL: https://github.com/apache/datafusion/pull/15906#discussion_r2068952607
##########
datafusion/expr/src/expr_rewriter/mod.rs:
##########
@@ -131,13 +131,25 @@ pub fn normalize_sorts(
}
/// Recursively replace all [`Column`] expressions in a given expression tree
with
-/// `Column` expressions provided by the hash map argument.
-pub fn replace_col(expr: Expr, replace_map: &HashMap<&Column, &Column>) ->
Result<Expr> {
Review Comment:
I don't wanna write a similar method for the PR, so made the method generic
```rust
pub fn replace_col_with_expr(
expr: Expr,
replace_map: &HashMap<Column, &Expr>,
) -> Result<Expr> {
expr.transform(|expr| {
Ok({
if let Expr::Column(c) = &expr {
match replace_map.get(c) {
Some(new_expr) =>
Transformed::yes((**new_expr).to_owned()),
None => Transformed::no(expr),
}
} else {
Transformed::no(expr)
}
})
})
.data()
}
```
--
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]