jonahgao commented on code in PR #8700:
URL: https://github.com/apache/arrow-datafusion/pull/8700#discussion_r1439026185
##########
datafusion/optimizer/src/eliminate_filter.rs:
##########
@@ -62,6 +62,14 @@ impl OptimizerRule for EliminateFilter {
}))),
}
}
+ LogicalPlan::Filter(Filter {
+ predicate: Expr::Literal(ScalarValue::Boolean(None)),
+ input,
+ ..
+ }) => Ok(Some(LogicalPlan::EmptyRelation(EmptyRelation {
Review Comment:
How about merging it into the previous `false` match arm like this 🤔?
```rust
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),
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]