pub fn simplify_regex_expr(
left: Box<Expr>,
op: Operator,
right: Box<Expr>,
) -> Result<Expr>Expand description
Tries to convert a regexp expression to a LIKE or Eq/NotEq expression.
This function also validates the regex pattern. And will return error if the pattern is invalid.
Typical cases this function can simplify:
- empty regex pattern to
LIKE '%' - literal regex patterns to
LIKE '%foo%' - full anchored regex patterns (e.g.
^foo$) to= 'foo' - partial anchored regex patterns (e.g.
^foo) toLIKE 'foo%' - combinations (alternatives) of the above, will be concatenated with
ORorAND EQ .*to NotNullNE .*means IS EMPTY
Dev note: unit tests of this function are in expr_simplifier.rs, case test_simplify_regex.