-
Notifications
You must be signed in to change notification settings - Fork 0
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
Extract result of find_common_exprs
into a struct
#4
Extract result of find_common_exprs
into a struct
#4
Conversation
find_common_exprs
into a strucgt
find_common_exprs
into a strucgtfind_common_exprs
into a struct
build_common_expr_project_plan(input, common_exprs).map(|new_input| { | ||
(new_window_expr_list, new_input, Some(window_expr_list)) | ||
(new_exprs_list, new_input, Some(original_exprs_list)) |
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.
I also renamed the local variables to follow the naming of the fields
fn find_common_exprs( | ||
&self, | ||
exprs_list: Vec<Vec<Expr>>, | ||
config: &dyn OptimizerConfig, | ||
expr_mask: ExprMask, | ||
) -> Result<Transformed<(Vec<Vec<Expr>>, FindCommonExprResult)>> { | ||
) -> Result<Transformed<FoundCommonExprs>> { |
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.
The point of the PR is to make this change and the rest of the changes are a consequence of doign so
.map(|new_input| (new_exprs, new_input)) | ||
} | ||
None => Ok((new_exprs, input)), | ||
.map_data(|common| match common { |
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.
This isn't quite as concise as the previous version but I do think it is more explicit and easier to follow
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.
I like this refactor. Indeed this is much easier to follow. Thanks @alamb!
* Make `CommonSubexprEliminate` top-down like * fix top-down recursion, fix unit tests to use real a Optimizer to verify behavior on plans * Extract result of `find_common_exprs` into a struct (#4) * Extract the result of find_common_exprs into a struct * Make naming consistent --------- Co-authored-by: Andrew Lamb <[email protected]>
Here is a proposed refactor of apache#11683
I found the type signature of this
Where
to be hard to follow
Thus I propose pulling this into an
enum
so the fields are namedI don't think this changes the logic or performance -- it is solely for readability
We can also merge apache#11683 and consider this proposal separately