This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 1aec8005928 [fix](invert index) fix error handling for match_regexp
resulting in an empty match. (#29234)
1aec8005928 is described below
commit 1aec8005928275f3294c03014169b3369717fe79
Author: zzzxl <[email protected]>
AuthorDate: Thu Dec 28 21:28:45 2023 +0800
[fix](invert index) fix error handling for match_regexp resulting in an
empty match. (#29234)
---
.../rowset/segment_v2/inverted_index/query/regexp_query.cpp | 10 ++++++++--
.../data/inverted_index_p0/test_index_match_regexp.out | 3 +++
.../suites/inverted_index_p0/test_index_match_regexp.groovy | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git
a/be/src/olap/rowset/segment_v2/inverted_index/query/regexp_query.cpp
b/be/src/olap/rowset/segment_v2/inverted_index/query/regexp_query.cpp
index 83c5401bac0..ee959e1da73 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index/query/regexp_query.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index/query/regexp_query.cpp
@@ -70,10 +70,12 @@ void RegexpQuery::add(const std::wstring& field_name, const
std::string& pattern
}
if (is_match) {
- terms.emplace_back(std::move(input));
- if (++count >= _max_expansions) {
+ if (_max_expansions > 0 && count >= _max_expansions) {
break;
}
+
+ terms.emplace_back(std::move(input));
+ count++;
}
_CLDECDELETE(term);
@@ -88,6 +90,10 @@ void RegexpQuery::add(const std::wstring& field_name, const
std::string& pattern
hs_free_database(database);
})
+ if (terms.empty()) {
+ return;
+ }
+
query.add(field_name, terms);
}
diff --git a/regression-test/data/inverted_index_p0/test_index_match_regexp.out
b/regression-test/data/inverted_index_p0/test_index_match_regexp.out
index eab27de65ee..f9a9caf6d74 100644
--- a/regression-test/data/inverted_index_p0/test_index_match_regexp.out
+++ b/regression-test/data/inverted_index_p0/test_index_match_regexp.out
@@ -14,3 +14,6 @@
-- !sql --
38
+-- !sql --
+0
+
diff --git
a/regression-test/suites/inverted_index_p0/test_index_match_regexp.groovy
b/regression-test/suites/inverted_index_p0/test_index_match_regexp.groovy
index 49156c22370..8c48204b586 100644
--- a/regression-test/suites/inverted_index_p0/test_index_match_regexp.groovy
+++ b/regression-test/suites/inverted_index_p0/test_index_match_regexp.groovy
@@ -85,6 +85,8 @@ suite("test_index_match_regexp", "p0"){
qt_sql """ select count() from test_index_match_regexp where request
match_regexp 's\$'; """
qt_sql """ select count() from test_index_match_regexp where request
match_regexp 'er\$'; """
qt_sql """ select count() from test_index_match_regexp where request
match_regexp '.*tickets.*'; """
+ qt_sql """ select count() from test_index_match_regexp where request
match_regexp 'nonexistence'; """
+
} finally {
//try_sql("DROP TABLE IF EXISTS ${testTable}")
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]