Skip to content

Conversation

@dmitriibugakov
Copy link
Contributor

Which issue does this PR close?

Closes #10288.

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 optimizer Optimizer rules label Apr 29, 2024
fn rewrite(
&self,
plan: LogicalPlan,
_config: &dyn OptimizerConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the code in this function uses this so it likely should not start with an underscore as that is a convention to indicate it's not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Omega359 clippy was failed with

Parameter config is only used in recursion. Consider prefixing it with an underscore: _config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh. My apologies, I didn't see that

@dmitriibugakov dmitriibugakov force-pushed the 10288-optimize-eliminate-filter branch 2 times, most recently from 027dbc3 to 9e0664f Compare April 30, 2024 07:48
@dmitriibugakov dmitriibugakov requested a review from Omega359 April 30, 2024 07:50
Some(false) | None => Ok(Transformed::yes(LogicalPlan::EmptyRelation(
EmptyRelation {
produce_one_row: false,
schema: unwrap_arc(input).schema().clone(),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
schema: unwrap_arc(input).schema().clone(),
schema: input.schema().clone(),

Could we remove the unwrap_arc here?

@dmitriibugakov dmitriibugakov force-pushed the 10288-optimize-eliminate-filter branch from 9e0664f to 4f893ee Compare April 30, 2024 16:42
@dmitriibugakov dmitriibugakov requested a review from jonahgao April 30, 2024 16:44
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.

Nice -- thank you @dmitrybugakov and @Omega359 -- this looks like a very nice improvement to me ❤️

..
}) => match v {
Some(true) => Ok(Transformed::yes(
self.rewrite(unwrap_arc(input), _config)?.data,
Copy link
Contributor

Choose a reason for hiding this comment

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

I almost wonder if this recursion is even necessary given that it already does ApplyOrder::TopDown the optimizer itself will call Self::rewrite on the inputs

In other words, it might be possible to do

Suggested change
self.rewrite(unwrap_arc(input), _config)?.data,
unwrap_arc(input)

@dmitriibugakov dmitriibugakov force-pushed the 10288-optimize-eliminate-filter branch from 4f893ee to 507f1c5 Compare April 30, 2024 19:42
@dmitriibugakov dmitriibugakov requested a review from alamb April 30, 2024 19:43
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.

Thanks @dmitrybugakov !

input,
..
}) => match v {
Some(true) => Ok(Transformed::yes(unwrap_arc(input))),
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

}

#[test]
fn eliminate_nested_filters() {
Copy link
Contributor

Choose a reason for hiding this comment

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

100% for the new test

@alamb alamb merged commit d48fdb0 into apache:main Apr 30, 2024
@dmitriibugakov dmitriibugakov deleted the 10288-optimize-eliminate-filter branch May 1, 2024 11:46
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.

Stop copying LogicalPlan and Exprs in EliminateFilter

4 participants