Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list slice utf8 #2212

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/include/function/list/functions/list_slice_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstring>

#include "common/types/ku_list.h"
#include "function/string/functions/substr_function.h"

namespace kuzu {
namespace function {
Expand Down Expand Up @@ -31,9 +32,8 @@ struct ListSlice {
common::ValueVector& resultValueVector) {
int64_t startIdx = (begin == 0) ? 1 : begin;
int64_t endIdx = (end == 0) ? str.len : end;
result.len = std::min(endIdx - startIdx + 1, str.len - startIdx + 1);
common::StringVector::addString(
&resultValueVector, result, (const char*)(str.getData() + startIdx - 1), result.len);
SubStr::operation(str, startIdx, std::min(endIdx - startIdx + 1, str.len - startIdx + 1),
result, resultValueVector);
}
};

Expand Down
4 changes: 4 additions & 0 deletions test/test_files/tinysnb/function/list.test
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ sdwe
ad


-LOG SliceUTF8String
-STATEMENT Return '这是一个中文句子'[2:5]
---- 1
是一个中

-LOG ListLenStructuredListOfInts
-STATEMENT MATCH (a:person) RETURN len(a.workedHours)
Expand Down