Skip to content

Commit

Permalink
[BugFix] append_trailing_char_if_absent return empty string for const…
Browse files Browse the repository at this point in the history
… empty strings (#13762)

(cherry picked from commit 27dd3c3)
  • Loading branch information
fzhedu authored and mergify[bot] committed Nov 21, 2022
1 parent d2634e6 commit 256ea9c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions be/src/exprs/vectorized/string_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,12 +1532,7 @@ ColumnPtr StringFunctions::append_trailing_char_if_absent(FunctionContext* conte
auto str = src_viewer.value(row);
auto tailing_char = tailing_viewer.value(row);

if (str.size == 0) {
dst_builder.append(tailing_char);
continue;
}

if (str.data[str.size - 1] == tailing_char.data[0]) {
if (str.size == 0 || str.data[str.size - 1] == tailing_char.data[0]) {
dst_builder.append(str);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion be/test/exprs/vectorized/string_fn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ PARALLEL_TEST(VecStringFunctionsTest, appendTrailingCharIfAbsentTest) {

ASSERT_EQ("qwer", v->get_data()[0].to_string());
ASSERT_EQ("qwer", v->get_data()[1].to_string());
ASSERT_EQ("r", v->get_data()[2].to_string());
ASSERT_EQ("", v->get_data()[2].to_string());
}

PARALLEL_TEST(VecStringFunctionsTest, appendTrailingCharIfAbsentNullTest) {
Expand Down

0 comments on commit 256ea9c

Please sign in to comment.