Skip to content

Commit 9f9ae5f

Browse files
branch-4.0: [Enhancement](RE2) Silence RE2 stderr in regexp function #60303 (#60328)
Cherry-picked from #60303 Co-authored-by: linrrarity <linzhenqi@selectdb.com>
1 parent 8029130 commit 9f9ae5f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

be/src/vec/functions/function_regexp.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ struct RegexpExtractEngine {
6464
// Try to compile with RE2 first, fallback to Boost.Regex if RE2 fails
6565
static bool compile(const StringRef& pattern, std::string* error_str,
6666
RegexpExtractEngine& engine, bool enable_extended_regex) {
67-
engine.re2_regex = std::make_unique<re2::RE2>(re2::StringPiece(pattern.data, pattern.size));
67+
re2::RE2::Options options;
68+
options.set_log_errors(false); // avoid RE2 printing to stderr; we handle errors ourselves
69+
engine.re2_regex =
70+
std::make_unique<re2::RE2>(re2::StringPiece(pattern.data, pattern.size), options);
71+
6872
if (engine.re2_regex->ok()) {
6973
return true;
7074
} else if (!enable_extended_regex) {

0 commit comments

Comments
 (0)