Skip to content

Commit 173f626

Browse files
committed
make a constant
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
1 parent 92e8015 commit 173f626

File tree

1 file changed

+3
-1
lines changed
  • datafusion/optimizer/src/simplify_expressions

1 file changed

+3
-1
lines changed

datafusion/optimizer/src/simplify_expressions/regex.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use regex_syntax::hir::{Capture, Hir, HirKind, Literal, Look};
2222
/// Maximum number of regex alternations (`foo|bar|...`) that will be expanded into multiple `LIKE` expressions.
2323
const MAX_REGEX_ALTERNATIONS_EXPANSION: usize = 4;
2424

25+
const ANY_CHAR_REGEX_PATTERN: &str = ".*";
26+
2527
/// Tries to convert a regexp expression to a `LIKE` or `Eq`/`NotEq` expression.
2628
///
2729
/// This function also validates the regex pattern. And will return error if the
@@ -46,7 +48,7 @@ pub fn simplify_regex_expr(
4648

4749
if let Expr::Literal(ScalarValue::Utf8(Some(pattern))) = right.as_ref() {
4850
// Handle the special case for ".*" pattern
49-
if pattern == ".*" {
51+
if pattern == ANY_CHAR_REGEX_PATTERN {
5052
let new_expr = if mode.not {
5153
// not empty
5254
let empty_lit = Box::new(lit(""));

0 commit comments

Comments
 (0)