Skip to content

docs: revise OptimizerRule trait method descriptions#22582

Open
jiengup wants to merge 1 commit into
apache:mainfrom
jiengup:patch-1
Open

docs: revise OptimizerRule trait method descriptions#22582
jiengup wants to merge 1 commit into
apache:mainfrom
jiengup:patch-1

Conversation

@jiengup
Copy link
Copy Markdown

@jiengup jiengup commented May 28, 2026

Updated the description of the OptimizerRule trait methods to reflect changes in the try_optimize and rewrite methods in Working with Exprs doc.

Which issue does this PR close?

  • Closes N/A

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 28, 2026
Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

@jiengup
Thanks for tightening up these optimizer rule docs.
I think one detail still needs a small correction before this lands, since it affects the main API shape users will copy from here.


- `name` - returns the name of the rule
- `try_optimize` - takes a `LogicalPlan` and returns an `Option<LogicalPlan>`. If the rule is able to optimize the plan, it returns `Some(LogicalPlan)` with the optimized plan. If the rule is not able to optimize the plan, it returns `None`.
- `rewrite` - takes a `LogicalPlan` and returns an `Transformed<LogicalPlan>`. If the rule is able to optimize the plan, it returns `Transformed::yes` with the optimized plan. If the rule is not able to optimize the plan, it returns `Transformed::no`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for updating this section. I think the rewrite description still needs one more tweak to match the actual OptimizerRule::rewrite API.

The method also receives &dyn OptimizerConfig and returns Result<Transformed<LogicalPlan>>, rather than just Transformed<LogicalPlan>. Since this PR is focused on fixing stale optimizer rule docs, it would be good to make the signature complete here so users implementing the trait have the right shape to follow.

Suggested wording: rewrite takes a LogicalPlan and &dyn OptimizerConfig, and returns Result<Transformed<LogicalPlan>>.

Small grammar note while you are here: this should be a Transformed<LogicalPlan> rather than an Transformed<LogicalPlan>.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, thanks for your suggestion. I'll make it clearer here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jiengup
Copy link
Copy Markdown
Author

jiengup commented May 31, 2026

@kosiew Please have a look at this version.

Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

@jiengup

Thanks of the iteration.

Looks 👍 to me

Updated the description of the `OptimizerRule` trait methods to reflect changes in the `try_optimize` and `rewrite` methods in `Working with `Expr`s` doc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants