-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add try_optimize method #4208
Add try_optimize method #4208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Job 👍. This is one of the things I prepare to do in the future.
Add a newmethed is a good way to keep backwards compatibility(I‘m blocked by it)
Thanks @andygrove !
@@ -20,7 +20,7 @@ use crate::utils::{ | |||
verify_not_disjunction, | |||
}; | |||
use crate::{utils, OptimizerConfig, OptimizerRule}; | |||
use datafusion_common::{context, plan_err, DataFusionError}; | |||
use datafusion_common::context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep DataFusionError
, following code we can use Result
instead of datafusion_common::Result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we could just do use datafusion_common::Result
Will we remove the existing |
in my opinion, It depends on can we refactor all rule, when we do all job, we can remove. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andygrove -- this is a much nicer API
@@ -20,7 +20,7 @@ use crate::utils::{ | |||
verify_not_disjunction, | |||
}; | |||
use crate::{utils, OptimizerConfig, OptimizerRule}; | |||
use datafusion_common::{context, plan_err, DataFusionError}; | |||
use datafusion_common::context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we could just do use datafusion_common::Result
Yes, exactly. This way we can update one rule at a time, and remove it when we are done. |
Benchmark runs are scheduled for baseline = 4653df4 and contender = 28ca3ee. 28ca3ee is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #4209
Rationale for this change
This PR aims to improve the API for optimizer rules by adding a new
try_optimize
method that returnsResult<Option<LogicalPlan>>
so that rules can now choose to returnOk(None)
if the rule is not applicable to the plan.What changes are included in this PR?
try_optimize
method toOptimizer
trait with a default implementation that calls the existingoptimize
method for backwards compatibilitydecorrelate_where_exists
to use this new approachAre these changes tested?
Relevant unit tests updated to expect new behavior.
Are there any user-facing changes?