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](sql function)Fix split_part function behavior #36231

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Changing split_part fucntion behavior
  • Loading branch information
liujiwen-up authored and yiguolei committed Jul 15, 2024
commit fe736c3a235079027a94a754cd86d3dc448f265a
12 changes: 12 additions & 0 deletions be/src/vec/functions/function_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,10 @@ class FunctionSplitPart : public IFunction {
reinterpret_cast<const char*>(str.data + pre_offset + 1),
(size_t)offset - pre_offset - 1},
i, res_chars, res_offsets);
} else if (num == 0) {
StringOP::push_value_string(
std::string_view {reinterpret_cast<const char*>(str.data), str.size},
i, res_chars, res_offsets);
} else {
StringOP::push_null_string(i, res_chars, res_offsets, null_map_data);
}
Expand Down Expand Up @@ -1572,6 +1576,10 @@ class FunctionSplitPart : public IFunction {
str.data + pre_offset + delimiter.size),
(size_t)offset - pre_offset - delimiter.size},
i, res_chars, res_offsets);
} else if (num == 0) {
StringOP::push_value_string(
std::string_view {reinterpret_cast<const char*>(str.data), str.size},
i, res_chars, res_offsets);
} else {
StringOP::push_null_string(i, res_chars, res_offsets, null_map_data);
}
Expand Down Expand Up @@ -1611,6 +1619,10 @@ class FunctionSplitPart : public IFunction {
(size_t)pre_offset - offset - delimiter.size)},
i, res_chars, res_offsets);
}
} else if (num == 0) {
StringOP::push_value_string(
std::string_view {reinterpret_cast<const char*>(str.data), str.size},
i, res_chars, res_offsets);
} else {
StringOP::push_null_string(i, res_chars, res_offsets, null_map_data);
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ suite("test_string_function", "arrow_flight_sql") {
qt_sql "select split_part('abc##123###xyz', '##', -1)"
qt_sql "select split_part('abc##123###xyz', '##', -2)"
qt_sql "select split_part('abc##123###xyz', '##', -4)"
qt_sql "select split_part('abc', '|', 1)"
qt_sql "select split_part('abc', '||', 1)"
qt_sql "select split_part('abc', '|', -1)"
qt_sql "select split_part('abc', '||', -1)"

qt_sql "select starts_with(\"hello world\",\"hello\");"
qt_sql "select starts_with(\"hello world\",\"world\");"
Expand Down