Skip to content

Commit

Permalink
fmt/clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Dec 29, 2021
1 parent 6d87ce7 commit 89e6d31
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions datafusion/src/optimizer/simplify_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ fn is_null(expr: &Expr) -> bool {
/// returns true if `haystack` looks like (needle OP X) or (X OP needle)
fn is_op_with(target_op: Operator, haystack: &Expr, needle: &Expr) -> bool {
match haystack {
Expr::BinaryExpr {
left,
op,
right,
} if op == &target_op && (needle == left.as_ref() || needle == right.as_ref()) => true,
Expr::BinaryExpr { left, op, right }
if op == &target_op
&& (needle == left.as_ref() || needle == right.as_ref()) =>
{
true
}
_ => false,
}
}
Expand Down Expand Up @@ -408,7 +409,7 @@ impl<'a> Simplifier<'a> {
return Ok(true);
}
}
return Ok(false);
Ok(false)
}
}

Expand Down Expand Up @@ -891,11 +892,7 @@ mod tests {
#[test]
fn test_simplify_and_or() {
let l = col("c2").gt(lit(5));
let r = binary_expr(
col("c1").lt(lit(6)),
Operator::Or,
col("c2").gt(lit(5)),
);
let r = binary_expr(col("c1").lt(lit(6)), Operator::Or, col("c2").gt(lit(5)));

// (c2 > 5) AND ((c1 < 6) OR (c2 > 5)) --> c2 > 5
let expr = binary_expr(l.clone(), Operator::And, r.clone());
Expand Down

0 comments on commit 89e6d31

Please sign in to comment.