Skip to content

Commit

Permalink
[bug](function) fix regexp_extract_all can't handle empty str
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Oct 20, 2023
1 parent 642c149 commit c998035
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions be/src/vec/functions/function_regexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ struct RegexpExtractAllImpl {
}

if (res_matches.empty()) {
StringOP::push_empty_string(index_now, result_data, result_offset);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ d
-- !sql --
['ab','c','c','c']

-- !sql_regexp_extract_all --
0
0
0
0

-- !sql --
a-b-c

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ suite("test_string_function_regexp") {
qt_sql "select regexp_extract_all('xxfs','f');"
qt_sql "select regexp_extract_all('asdfg', '(z|x|c|)');"
qt_sql "select regexp_extract_all('abcdfesscca', '(ab|c|)');"
qt_sql_regexp_extract_all "select regexp_extract_all('', '\"([^\"]+)\":'), length(regexp_extract_all('', '\"([^\"]+)\":')) from test_string_function_regexp;"

qt_sql "SELECT regexp_replace('a b c', \" \", \"-\");"
qt_sql "SELECT regexp_replace('a b c','(b)','<\\\\1>');"
Expand Down

0 comments on commit c998035

Please sign in to comment.