diff --git a/velox/functions/sparksql/RegexFunctions.cpp b/velox/functions/sparksql/RegexFunctions.cpp index 734c7aea5592..f882f8324677 100644 --- a/velox/functions/sparksql/RegexFunctions.cpp +++ b/velox/functions/sparksql/RegexFunctions.cpp @@ -53,6 +53,14 @@ void ensureRegexIsCompatible( // instead adds the character ]. } else if (*c == ']' && charClassStart + 1 != c) { charClassStart = nullptr; + } else if (*c == '(' && c + 3 < pattern.end() && *(c + 1) == '?') { + // RE2 doesn't support lookaround (lookahead or lookbehind), so we should exclude such patterns: + // (?=), (?!), (?<=), (?