Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

qazxcdswe123
Copy link
Contributor

Follow up for #15027


  1. Cleanup deprecated function in optimizer
  2. Inlined optimize_plan_node

I've also noticed that, all supports_rewrite return true and not used anywhere, should we also remove it?

Remove intermediate `optimize_plan_node` function and directly call `rule.rewrite()` method
@github-actions github-actions bot added the optimizer Optimizer rules label Mar 6, 2025
Copy link
Contributor

@ctsk ctsk left a 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 🙈

Comment on lines +289 to +293
{
let rule: &dyn OptimizerRule = self.rule;
let config: &dyn OptimizerConfig = self.config;
rule.rewrite(node, config)
}
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe unnecessary?

@alamb alamb changed the title Cleanup deprecated function in optimizer Cleanup deprecated function in optimizer: remove OptimizerRule::try_optimize Mar 6, 2025
Copy link
Contributor

@alamb alamb left a 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
Copy link
Contributor

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`]
Copy link
Contributor

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

@alamb alamb changed the title Cleanup deprecated function in optimizer: remove OptimizerRule::try_optimize Remove deprecated function OptimizerRule::try_optimize Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants