Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Nov 16, 2024
1 parent 2be78c3 commit 9e40e7d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2865,10 +2865,7 @@ mod tests {
);

// single character
assert_change(
regex_match(col("c1"), lit("x")),
col("c1").like(lit("%x%")),
);
assert_change(regex_match(col("c1"), lit("x")), col("c1").like(lit("%x%")));

// single word
assert_change(
Expand Down Expand Up @@ -2977,32 +2974,37 @@ mod tests {
// OR-chain
assert_change(
regex_match(col("c1"), lit("foo|bar|baz")),
col("c1").like(lit("%foo%"))
col("c1")
.like(lit("%foo%"))
.or(col("c1").like(lit("%bar%")))
.or(col("c1").like(lit("%baz%"))),
);
assert_change(
regex_match(col("c1"), lit("foo|x|baz")),
col("c1").like(lit("%foo%"))
col("c1")
.like(lit("%foo%"))
.or(col("c1").like(lit("%x%")))
.or(col("c1").like(lit("%baz%"))),
);
assert_change(
regex_not_match(col("c1"), lit("foo|bar|baz")),
col("c1").not_like(lit("%foo%"))
col("c1")
.not_like(lit("%foo%"))
.and(col("c1").not_like(lit("%bar%")))
.and(col("c1").not_like(lit("%baz%"))),
);
// both anchored expressions (translated to equality) and unanchored
assert_change(
regex_match(col("c1"), lit("foo|^x$|baz")),
col("c1").like(lit("%foo%"))
col("c1")
.like(lit("%foo%"))
.or(col("c1").eq(lit("x")))
.or(col("c1").like(lit("%baz%"))),
);
assert_change(
regex_not_match(col("c1"), lit("foo|^bar$|baz")),
col("c1").not_like(lit("%foo%"))
col("c1")
.not_like(lit("%foo%"))
.and(col("c1").not_eq(lit("bar")))
.and(col("c1").not_like(lit("%baz%"))),
);
Expand Down

0 comments on commit 9e40e7d

Please sign in to comment.