-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: remove filters with null constants #8700
feat: remove filters with null constants #8700
Conversation
predicate: Expr::Literal(ScalarValue::Boolean(None)), | ||
input, | ||
.. | ||
}) => Ok(Some(LogicalPlan::EmptyRelation(EmptyRelation { |
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.
How about merging it into the previous false
match arm like this 🤔?
fn try_optimize(
&self,
plan: &LogicalPlan,
_config: &dyn OptimizerConfig,
) -> Result<Option<LogicalPlan>> {
match plan {
LogicalPlan::Filter(Filter {
predicate: Expr::Literal(ScalarValue::Boolean(v)),
input,
..
}) => {
match *v {
// input also can be filter, apply again
Some(true) => Ok(Some(
self.try_optimize(input, _config)?
.unwrap_or_else(|| input.as_ref().clone()),
)),
Some(false) | None => {
Ok(Some(LogicalPlan::EmptyRelation(EmptyRelation {
produce_one_row: false,
schema: input.schema().clone(),
})))
}
}
}
_ => Ok(None),
}
}
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.
Updated
bcbf71f
to
3cc08f7
Compare
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.
Looks good to me!
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.
Looks great -- thank you @asimsedhain and @jonahgao for the review
Which issue does this PR close?
Closes #8689
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?