Skip to content

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?

@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 🙈

@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

/// Try to rewrite `plan` to an optimized form, returning `Transformed::yes`
/// 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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

I also marked deprecated supports_rewrite in this PR as it's only a one line change

@alamb alamb changed the title Cleanup deprecated function in optimizer: remove OptimizerRule::try_optimize Remove deprecated function OptimizerRule::try_optimize Mar 6, 2025
@qazxcdswe123 qazxcdswe123 force-pushed the cleanup-optimizer branch 2 times, most recently from c50f52e to 9870236 Compare March 7, 2025 13:16
@qazxcdswe123 qazxcdswe123 marked this pull request as draft March 7, 2025 13:44
@qazxcdswe123 qazxcdswe123 marked this pull request as ready for review March 7, 2025 13:48
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 @comphead -- this is a very nice improcement

None
}

/// Does this rule support rewriting owned plans (rather than by reference)?
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

fn f_down(&mut self, node: LogicalPlan) -> Result<Transformed<LogicalPlan>> {
if self.apply_order == ApplyOrder::TopDown {
optimize_plan_node(node, self.rule, self.config)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

minor is that it is strange to have this second level of nesting braces -- we can remove it as a follow on PR I think

@alamb alamb merged commit 17e8fa7 into apache:main Mar 7, 2025
24 checks passed
danila-b pushed a commit to danila-b/datafusion that referenced this pull request Mar 8, 2025
* chore: cleanup deprecated optimizer API since version <= 40

follow up of apache#15027

* chore: inlined `optimize_plan_node`

And also removed out dated comment

* chore: deprecate `supports_rewrite` function
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