Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Originally requested in #7883, which got closed by #8276
Looks like that PR added support to OR to propagate_constraints but missed OR out of apply_operator (which is used by evaluate_bounds) -
datafusion/datafusion/expr/src/interval_arithmetic.rs
Lines 773 to 787 in e9b9645
| pub fn apply_operator(op: &Operator, lhs: &Interval, rhs: &Interval) -> Result<Interval> { | |
| match *op { | |
| Operator::Eq => lhs.equal(rhs), | |
| Operator::NotEq => lhs.equal(rhs)?.not(), | |
| Operator::Gt => lhs.gt(rhs), | |
| Operator::GtEq => lhs.gt_eq(rhs), | |
| Operator::Lt => lhs.lt(rhs), | |
| Operator::LtEq => lhs.lt_eq(rhs), | |
| Operator::And => lhs.and(rhs), | |
| Operator::Plus => lhs.add(rhs), | |
| Operator::Minus => lhs.sub(rhs), | |
| Operator::Multiply => lhs.mul(rhs), | |
| Operator::Divide => lhs.div(rhs), | |
| _ => internal_err!("Interval arithmetic does not support the operator {op}"), | |
| } |
Seems like this should just be added?
To Reproduce
#[test]
fn test_evaluate_bounds_bool() -> Result<()> {
let schema = Schema::new(vec![
Field::new("a", DataType::Boolean, false),
Field::new("b", DataType::Boolean, false),
]);
let a = Arc::new(Column::new("a", 0)) as _;
let b = Arc::new(Column::new("b", 1)) as _;
// Test OR bounds - currently not working
let or_expr = binary_expr(Arc::clone(&a), Operator::Or, Arc::clone(&b), &schema)?;
let or_bounds = or_expr.evaluate_bounds(&[
&Interval::make(Some(true), Some(true))?,
&Interval::make(Some(false), Some(false))?,
])?;
assert_eq!(or_bounds, Interval::make(Some(true), Some(true))?);
// Test AND bounds - working fine
let and_expr =
binary_expr(Arc::clone(&a), Operator::And, Arc::clone(&b), &schema)?;
let and_bounds = and_expr.evaluate_bounds(&[
&Interval::make(Some(true), Some(true))?,
&Interval::make(Some(false), Some(false))?,
])?;
assert_eq!(and_bounds, Interval::make(Some(false), Some(false))?);
Ok(())
}Expected behavior
Looks like this test should pass.
Additional context
I have a PR to fix, will submit shortly.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity