Skip to content

Commit

Permalink
[function](char) change char function behaviour same with mysql (#30034)
Browse files Browse the repository at this point in the history
select char(0) = '\0';
should return true;
  • Loading branch information
zhangstar333 authored and Doris-Extras committed Jan 18, 2024
1 parent dcc9cf9 commit e894911
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions be/src/vec/functions/function_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,7 @@ class FunctionIntToChar : public IFunction {
void integer_to_char_(int line_num, const int* num, ColumnString::Chars& chars,
IColumn::Offsets& offsets) const {
if (0 == *num) {
chars.push_back(' ');
chars.push_back('\0');
offsets[line_num] = offsets[line_num - 1] + 1;
return;
}
Expand All @@ -3257,7 +3257,7 @@ class FunctionIntToChar : public IFunction {
}
offsets[line_num] = offsets[line_num - 1] + k + 1;
for (; k >= 0; --k) {
chars.push_back(bytes[k] ? bytes[k] : ' ');
chars.push_back(bytes[k] ? bytes[k] : '\0');
}
#else
int k = 0;
Expand All @@ -3268,7 +3268,7 @@ class FunctionIntToChar : public IFunction {
}
offsets[line_num] = offsets[line_num - 1] + 4 - k;
for (; k < 4; ++k) {
chars.push_back(bytes[k] ? bytes[k] : ' ');
chars.push_back(bytes[k] ? bytes[k] : '\0');
}
#endif
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,7 @@ suite("test_string_function", "arrow_flight_sql") {
qt_sql_func_char6 """ select char(k1) from test_function_char order by k1; """
qt_sql_func_char7 """ select char(k1, k2, k3, k4) from test_function_char order by k1, k2, k3, k4; """
qt_sql_func_char8 """ select char(k1, k2, k3, k4, 65) from test_function_char order by k1, k2, k3, k4; """
qt_sql_func_char9 """ select char(0) = ' '; """
qt_sql_func_char10 """ select char(0) = '\0'; """

}

0 comments on commit e894911

Please sign in to comment.