From 220875256e1b713ac6563a5a82173ae1d57bcb78 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:41:31 +0800 Subject: [PATCH] [Refactor] Chop too large hyperscan regex pattern when logging it on an error (backport #52467) (#52528) Co-authored-by: satanson --- be/src/exprs/vectorized/like_predicate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/be/src/exprs/vectorized/like_predicate.cpp b/be/src/exprs/vectorized/like_predicate.cpp index b59a97f123068..e8248880dfc52 100644 --- a/be/src/exprs/vectorized/like_predicate.cpp +++ b/be/src/exprs/vectorized/like_predicate.cpp @@ -36,7 +36,9 @@ bool LikePredicate::hs_compile_and_alloc_scratch(const std::string& pattern, Lik if (hs_compile(pattern.c_str(), HS_FLAG_ALLOWEMPTY | HS_FLAG_DOTALL | HS_FLAG_UTF8 | HS_FLAG_SINGLEMATCH, HS_MODE_BLOCK, nullptr, &state->database, &state->compile_err) != HS_SUCCESS) { std::stringstream error; - error << "Invalid hyperscan expression: " << std::string(slice.data, slice.size) << ": " + auto chopped_size = std::min(slice.size, 64); + auto ellipsis = (chopped_size < slice.size) ? "..." : ""; + error << "Invalid hyperscan expression: " << std::string(slice.data, chopped_size) << ellipsis << ": " << state->compile_err->message << PROMPT_INFO; LOG(WARNING) << error.str().c_str(); hs_free_compile_error(state->compile_err);