From 06e7c14320d7dc39a97c4ccaadd79e208d470ee3 Mon Sep 17 00:00:00 2001 From: amory Date: Fri, 2 Jun 2023 14:47:24 +0800 Subject: [PATCH] [Improve](json-array) Support json array with nereids bool (#20248) Support json array with nereids bool now : ``` set enable_nereids_planner=true; mysql> SELECT json_array(1, "abc", NULL, TRUE, '10:00:00'); +----------------------------------------------+ | json_array(1, 'abc', NULL, TRUE, '10:00:00') | +----------------------------------------------+ | [1,"abc",null,false,"10:00:00"] | +----------------------------------------------+ 1 row in set (0.02 sec) ``` nereids boolean is "true"/"false" is not '0' /'1' , so we always get false --- be/src/vec/functions/function_json.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/be/src/vec/functions/function_json.cpp b/be/src/vec/functions/function_json.cpp index e78bd1ba82..e4f955ae0a 100644 --- a/be/src/vec/functions/function_json.cpp +++ b/be/src/vec/functions/function_json.cpp @@ -547,7 +547,9 @@ struct JsonParser<'1'> { // bool static void update_value(StringParser::ParseResult& result, rapidjson::Value& value, StringRef data, rapidjson::Document::AllocatorType& allocator) { - value.SetBool((*data.data == '1') ? true : false); + DCHECK(data.size == 1 || strncmp(data.data, "true", 4) == 0 || + strncmp(data.data, "false", 5) == 0); + value.SetBool((*data.data == '1' || *data.data == 't') ? true : false); } };