martin-g commented on code in PR #25862:
URL: https://github.com/apache/datafusion/pull/25862#discussion_r4131029113
##########
datafusion/physical-plan/src/filter.rs:
##########
@@ -1207,6 +1281,34 @@ fn collect_null_rejecting_columns(predicate: &Arc<dyn
PhysicalExpr>) -> HashSet<
columns
}
+/// Returns the checked column index, and whether the check is `IS NULL`, when
+/// `predicate` is a bare `IS NULL` or `IS NOT NULL` check on a column.
+pub(crate) fn null_check_column(
+ predicate: &Arc<dyn PhysicalExpr>,
+) -> Option<(usize, bool)> {
+ // One type check keeps every other predicate cheap.
+ let type_id = (predicate.as_ref() as &dyn Any).type_id();
+ let (arg, is_null) = if type_id == TypeId::of::<IsNullExpr>() {
+ (predicate.downcast_ref::<IsNullExpr>()?.arg(), true)
+ } else if type_id == TypeId::of::<IsNotNullExpr>() {
+ (predicate.downcast_ref::<IsNotNullExpr>()?.arg(), false)
+ } else {
+ return None;
+ };
Review Comment:
```suggestion
if let Some(expr) = predicate.downcast_ref::<IsNullExpr>() {
Some((expr.arg(), true))
} else if let Some(expr) = predicate.downcast_ref::<IsNotNullExpr>() {
Some((expr.arg(), false))
} else {
None
}
```
a bit simpler
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]