Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Apr 6, 2024

Which issue does this PR close?

Part of #9637

Rationale for this change

I found this while working on #9913 with @peter-toth

Calling LogicalPlan::expressions() does a copy of the expressions, but this function simply needs to check them

What changes are included in this PR?

  1. Use TreeNode API to visit expressions rather than LogicalPlan::expressions()

Are these changes tested?

Covered by existing unit tests

Are there any user-facing changes?

(Slightly) faster planning, and fewer copies during planning

@github-actions github-actions bot added the optimizer Optimizer rules label Apr 6, 2024
fn check_plan(plan: &LogicalPlan) -> Result<()> {
plan.apply(&mut |plan: &LogicalPlan| {
for expr in plan.expressions().iter() {
plan.inspect_expressions(|expr| {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the line that voids a copy

Copy link
Member

Choose a reason for hiding this comment

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

A great catch! expressions() will invoke clone() inside, we can notice it to reduce some loss

Copy link
Contributor

@peter-toth peter-toth left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @alamb!

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

👍

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.

4 participants