-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Remove deprecated function OptimizerRule::try_optimize
#15051
base: main
Are you sure you want to change the base?
Conversation
Remove intermediate `optimize_plan_node` function and directly call `rule.rewrite()` method
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.
Just some stylistic comments. I don't know this bit of code well enough to comment on more 🙈
{ | ||
let rule: &dyn OptimizerRule = self.rule; | ||
let config: &dyn OptimizerConfig = self.config; | ||
rule.rewrite(node, config) | ||
} |
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'd just write
self.rule.rewrite(node, self.config)
:)
@@ -386,7 +354,10 @@ impl Optimizer { | |||
&mut Rewriter::new(apply_order, rule.as_ref(), config), | |||
), | |||
// rule handles recursion itself | |||
None => optimize_plan_node(new_plan, rule.as_ref(), config), | |||
None => { | |||
let rule: &dyn OptimizerRule = rule.as_ref(); |
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.
Maybe unnecessary?
optimizer
optimizer
: remove OptimizerRule::try_optimize
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.
Thank you @qazxcdswe123 and @ctsk for the review
I think @ctsk 's comments and suggestions are worth considering and ideally doing before we merge this PR but I don't think they are strictly necessary and we could do them as follow on PRs as well
@@ -107,7 +89,7 @@ pub trait OptimizerRule: Debug { | |||
/// if the plan was rewritten and `Transformed::no` if it was not. | |||
/// | |||
/// Note: this function is only called if [`Self::supports_rewrite`] returns |
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 think after this PR supports_rewrite
becomes a noop (doesn't do anything) so I recommend we also mark it as deprecated as well (deprecated as of 47.0.0)
@@ -62,8 +62,7 @@ impl OptimizerRule for SimplifyExpressions { | |||
true | |||
} | |||
|
|||
/// if supports_owned returns true, the Optimizer calls | |||
/// [`Self::rewrite`] instead of [`Self::try_optimize`] | |||
/// if supports_owned returns true, the Optimizer calls [`Self::rewrite`] |
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 don't understand what this comments means anymore -- I think we can simply delete it
optimizer
: remove OptimizerRule::try_optimize
OptimizerRule::try_optimize
Follow up for #15027
optimizer
optimize_plan_node
I've also noticed that, all
supports_rewrite
return true and not used anywhere, should we also remove it?