This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit e894911cdaa72a0f89e1f6ab0a42522a85f498f0
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Wed Jan 17 17:15:06 2024 +0800

    [function](char) change char function behaviour same with mysql (#30034)
    
    select char(0) = '\0';
    should return true;
---
 be/src/vec/functions/function_string.h                |   6 +++---
 .../string_functions/test_string_function.out         | Bin 3360 -> 3418 bytes
 .../string_functions/test_string_function.groovy      |   2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/be/src/vec/functions/function_string.h 
b/be/src/vec/functions/function_string.h
index 79b5205640a..0a4b3432015 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -3243,7 +3243,7 @@ private:
     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;
         }
@@ -3257,7 +3257,7 @@ private:
         }
         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;
@@ -3268,7 +3268,7 @@ private:
         }
         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
     }
diff --git 
a/regression-test/data/query_p0/sql_functions/string_functions/test_string_function.out
 
b/regression-test/data/query_p0/sql_functions/string_functions/test_string_function.out
index b51fb32d615..118c58c4910 100644
Binary files 
a/regression-test/data/query_p0/sql_functions/string_functions/test_string_function.out
 and 
b/regression-test/data/query_p0/sql_functions/string_functions/test_string_function.out
 differ
diff --git 
a/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function.groovy
 
b/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function.groovy
index 4f9faac47f9..cee30808b84 100644
--- 
a/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/string_functions/test_string_function.groovy
@@ -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'; """
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to