[Bug] Fix the core problem of function split_part and add the UT of core case (#4721)
issue:#4720
This commit is contained in:
@ -984,7 +984,7 @@ StringVal StringFunctions::split_part(FunctionContext* context, const StringVal&
|
||||
for (int i = 1; i <= field.val; i++) { // find
|
||||
int last_index = i - 1;
|
||||
find[last_index] = index_of(content.ptr, 0, content.len, delimiter.ptr, 0, delimiter.len, from);
|
||||
from = find[last_index] + 1;
|
||||
from = find[last_index] + delimiter.len;
|
||||
if (find[last_index] == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -178,6 +178,10 @@ TEST_F(StringFunctionsTest, split_part) {
|
||||
|
||||
ASSERT_EQ(AnyValUtil::from_string_temp(context, std::string("")),
|
||||
StringFunctions::split_part(context, StringVal("abcdabda"), StringVal("a"), 4));
|
||||
|
||||
ASSERT_EQ(AnyValUtil::from_string_temp(context, std::string("#123")),
|
||||
StringFunctions::split_part(context, StringVal("abc###123###234"), StringVal("##"), 2));
|
||||
|
||||
delete context;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user