Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ch-sc committed Jan 3, 2025
1 parent b56910a commit ab24ce1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
15 changes: 9 additions & 6 deletions datafusion/expr/src/interval_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,10 +871,10 @@ pub fn apply_operator(op: &Operator, lhs: &Interval, rhs: &Interval) -> Result<I
NullableInterval::from(lhs)
.apply_operator(op, &NullableInterval::from(rhs))
.and_then(|x| {
x.values().cloned().ok_or(DataFusionError::Internal(
"Unexpected null value interval".to_string(),
))
})
x.values().cloned().ok_or(DataFusionError::Internal(
"Unexpected null value interval".to_string(),
))
})
}
_ => internal_err!("Interval arithmetic does not support the operator {op}"),
}
Expand Down Expand Up @@ -1218,7 +1218,7 @@ pub fn satisfy_greater(
// Right-hand side: <------------0--======---->
// No intersection, infeasible to propagate:
Ok(None)
}
};
}

// Only the lower bound of left hand side and the upper bound of the right
Expand Down Expand Up @@ -2586,7 +2586,10 @@ mod tests {
];
for (first, second, expected) in possible_cases {
let union = first.union(second.clone())?.unwrap();
println!("\nleft:{:?} right:{:?} \nunion: {} expected:{:?}", first, second, &union, expected);
println!(
"\nleft:{:?} right:{:?} \nunion: {} expected:{:?}",
first, second, &union, expected
);
assert_eq!(union, expected)
}

Expand Down
19 changes: 12 additions & 7 deletions datafusion/physical-expr/src/intervals/cp_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,14 @@ pub fn propagate_comparison(
) -> Result<Option<(Interval, Interval)>> {
if parent == &Interval::CERTAINLY_TRUE {
match op {
Operator::Eq | Operator::IsNotDistinctFrom => left_child.intersect(right_child).map(|result| {
result.map(|intersection| (intersection.clone(), intersection))
}),
Operator::NotEq | Operator::IsDistinctFrom => left_child.union(right_child).map(|result| {
result.map(|unin| (unin.clone(), unin))
}),
Operator::Eq | Operator::IsNotDistinctFrom => {
left_child.intersect(right_child).map(|result| {
result.map(|intersection| (intersection.clone(), intersection))
})
}
Operator::NotEq | Operator::IsDistinctFrom => left_child
.union(right_child)
.map(|result| result.map(|unin| (unin.clone(), unin))),
Operator::Gt => satisfy_greater(left_child, right_child, true),
Operator::GtEq => satisfy_greater(left_child, right_child, false),
Operator::Lt => satisfy_greater(right_child, left_child, true)
Expand All @@ -332,7 +334,10 @@ pub fn propagate_comparison(
}
} else if parent == &Interval::CERTAINLY_FALSE {
match op {
Operator::Eq | Operator::IsNotDistinctFrom | Operator::NotEq | Operator::IsDistinctFrom => {
Operator::Eq
| Operator::IsNotDistinctFrom
| Operator::NotEq
| Operator::IsDistinctFrom => {
// TODO: Propagation is not possible until we support interval sets.
Ok(None)
}
Expand Down

0 comments on commit ab24ce1

Please sign in to comment.