Skip to content

Commit a1bc263

Browse files
committed
Rename predicate_eval to predicate_bounds
1 parent 4a22dfc commit a1bc263

File tree

4 files changed

+301
-221
lines changed

4 files changed

+301
-221
lines changed

datafusion/expr-common/src/interval_arithmetic.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,16 @@ impl NullableInterval {
17621762
}
17631763
}
17641764

1765+
/// Return true if the value is definitely not true (either null or false).
1766+
pub fn is_certainly_not_true(&self) -> bool {
1767+
match self {
1768+
Self::Null { .. } => true,
1769+
Self::MaybeNull { values } | Self::NotNull { values } => {
1770+
values == &Interval::CERTAINLY_FALSE
1771+
}
1772+
}
1773+
}
1774+
17651775
/// Return true if the value is definitely false (and not null).
17661776
pub fn is_certainly_false(&self) -> bool {
17671777
match self {

datafusion/expr/src/expr_schema.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use super::{predicate_eval, Between, Expr, Like};
18+
use super::{predicate_bounds, Between, Expr, Like};
1919
use crate::expr::{
2020
AggregateFunction, AggregateFunctionParams, Alias, BinaryExpr, Cast, InList,
2121
InSubquery, Placeholder, ScalarFunction, TryCast, Unnest, WindowFunction,
@@ -321,17 +321,18 @@ impl ExprSchemable for Expr {
321321
}
322322
};
323323

324-
match predicate_eval::const_eval_predicate(
324+
let bounds = predicate_bounds::evaluate_bounds(
325325
w,
326326
is_null,
327327
input_schema,
328-
) {
329-
// Const evaluation was inconclusive or determined the branch
330-
// would be taken
331-
None | Some(true) => Some(Ok(())),
332-
// Const evaluation proves the branch will never be taken.
328+
);
329+
if bounds.is_certainly_not_true() {
330+
// The branch will certainly never be taken.
333331
// The most common pattern for this is `WHEN x IS NOT NULL THEN x`.
334-
Some(false) => None,
332+
None
333+
} else {
334+
// The branch might be taken
335+
Some(Ok(()))
335336
}
336337
}
337338
}

datafusion/expr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub mod async_udf;
7070
pub mod statistics {
7171
pub use datafusion_expr_common::statistics::*;
7272
}
73-
mod predicate_eval;
73+
mod predicate_bounds;
7474
pub mod ptr_eq;
7575
pub mod test;
7676
pub mod tree_node;

0 commit comments

Comments
 (0)