-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve documentation for ExprVisitor, port simple uses to new walking function #4916
Conversation
@@ -83,20 +85,16 @@ pub fn grouping_set_to_exprlist(group_expr: &[Expr]) -> Result<Vec<Expr>> { | |||
} | |||
} | |||
|
|||
/// Recursively walk an expression tree, collecting the unique set of column names | |||
/// Recursively walk an expression tree, collecting the unique set of columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is a pretty good example of reducing the ceremony required do to a walk of an expr by using inspect_expr_pre
rather than having to define a visitor explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great to me.
Sorry for review it too late. I'm really busy to working recently....
pub fn expr_to_columns(expr: &Expr, accum: &mut HashSet<Column>) -> Result<()> { | ||
inspect_expr_pre(expr, |expr| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this change❤️
Thanks @jackwener -- I totally understand! |
Benchmark runs are scheduled for baseline = ba9fc12 and contender = ef4ca7e. ef4ca7e is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
N/A
Rationale for this change
Follow on to #4906
Some uses of
ExpressionVisitor
need its full power (visit both on pre/post traversal, see https://github.com/apache/arrow-datafusion/blob/d49c805c93498b542c130c77099b719f2a4ea8ba/datafusion/optimizer/src/common_subexpr_eliminate.rs#L421) but several uses just need a simple town down traversal.#4906 added a convenience function to do that traversal.
What changes are included in this PR?
walk_expr_down
toinspect_expr_pre
inspect_expr_pre
to simplify themI am hoping to do something similar to ExpressionMutator for rewriting exprs.
Are these changes tested?
Covered by existing tests