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

morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git

commit 0d099f78d92042fe98330baae1ff9cf77ee4a653
Author: Pxl <952130...@qq.com>
AuthorDate: Thu Mar 17 10:08:31 2022 +0800

    [fix](vectorized) fix core dump on get_json_string and add some ut (#8496)
---
 be/CMakeLists.txt                             |  6 ++-
 be/src/vec/functions/function_json.cpp        |  7 +--
 be/test/exprs/array_functions_test.cpp        |  2 +-
 be/test/http/message_body_sink_test.cpp       |  3 +-
 be/test/olap/bit_field_test.cpp               |  4 +-
 be/test/olap/column_reader_test.cpp           |  4 +-
 be/test/olap/delete_handler_test.cpp          | 12 ++---
 be/test/olap/delta_writer_test.cpp            | 15 +++---
 be/test/olap/options_test.cpp                 |  8 +--
 be/test/olap/rowset/alpha_rowset_test.cpp     |  2 +-
 be/test/olap/rowset/beta_rowset_test.cpp      |  3 +-
 be/test/olap/rowset/rowset_converter_test.cpp |  2 +-
 be/test/olap/run_length_byte_test.cpp         |  4 +-
 be/test/olap/run_length_integer_test.cpp      |  8 +--
 be/test/olap/schema_change_test.cpp           |  7 +--
 be/test/runtime/memory_scratch_sink_test.cpp  |  8 +--
 be/test/runtime/user_function_cache_test.cpp  |  9 ++--
 be/test/util/arrow/arrow_work_flow_test.cpp   |  8 +--
 be/test/vec/function/CMakeLists.txt           |  1 +
 be/test/vec/function/function_json_test.cpp   | 74 +++++++++++++++++++++++++++
 build.sh                                      |  8 +--
 run-be-ut.sh                                  |  5 ++
 22 files changed, 145 insertions(+), 55 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 5680b8c..7c83019 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -363,7 +363,7 @@ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} 
-DBOOST_SYSTEM_NO_DEPRECATED")
 # Enable the cpu and heap profile of brpc
 set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
-if (USE_LDD)
+if (USE_LLD)
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fuse-ld=lld")
 endif ()
 
@@ -677,6 +677,10 @@ set (TEST_LINK_LIBS ${DORIS_LINK_LIBS}
 set(BUILD_SHARED_LIBS OFF)
 
 if (${MAKE_TEST} STREQUAL "ON")
+    if (USE_LLD)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
+    endif ()
+
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage 
-DGTEST_USE_OWN_TR1_TUPLE=0")
     SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs 
-ftest-coverage -lgcov")
     add_definitions(-DBE_TEST)
diff --git a/be/src/vec/functions/function_json.cpp 
b/be/src/vec/functions/function_json.cpp
index ee4b6c9..2019ac5 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -46,7 +46,9 @@ void char_split(std::vector<T>& res, const U& var, char p) {
     int pos = start;
     int end = var.length();
     while (pos < end) {
-        while (var[pos] != p && pos < end) pos++;
+        while (var[pos] != p && pos < end) {
+            pos++;
+        }
         res.emplace_back(&var[start], pos - start);
         pos++;
         start = pos;
@@ -325,7 +327,7 @@ struct GetJsonString {
             const auto l_raw = reinterpret_cast<const char*>(&ldata[loffsets[i 
- 1]]);
 
             int r_size = roffsets[i] - roffsets[i - 1] - 1;
-            const auto r_raw = reinterpret_cast<const char*>(&rdata[loffsets[i 
- 1]]);
+            const auto r_raw = reinterpret_cast<const char*>(&rdata[roffsets[i 
- 1]]);
 
             if (null_map[i]) {
                 StringOP::push_null_string(i, res_data, res_offsets, null_map);
@@ -342,7 +344,6 @@ struct GetJsonString {
             const int max_string_len = 65535;
 
             if (root == nullptr || root->IsNull()) {
-                null_map[i] = 1;
                 StringOP::push_null_string(i, res_data, res_offsets, null_map);
             } else if (root->IsString()) {
                 const auto ptr = root->GetString();
diff --git a/be/test/exprs/array_functions_test.cpp 
b/be/test/exprs/array_functions_test.cpp
index 8e410e2..8ed72a1 100644
--- a/be/test/exprs/array_functions_test.cpp
+++ b/be/test/exprs/array_functions_test.cpp
@@ -47,7 +47,7 @@ public:
 TEST_F(ArrayFunctionsTest, array) {
     // Int array
     {
-        FunctionContext::TypeDesc childTypeDesc;
+        FunctionContext::TypeDesc childTypeDesc {};
         childTypeDesc.type = FunctionContext::TYPE_INT;
 
         _context->impl()->_return_type.type = FunctionContext::TYPE_ARRAY;
diff --git a/be/test/http/message_body_sink_test.cpp 
b/be/test/http/message_body_sink_test.cpp
index d8e5d7b..421308d 100644
--- a/be/test/http/message_body_sink_test.cpp
+++ b/be/test/http/message_body_sink_test.cpp
@@ -47,7 +47,8 @@ TEST_F(MessageBodySinkTest, file_sink) {
         char buf[256];
         memset(buf, 0, 256);
         int fd = open("././body_sink_test_file_sink", O_RDONLY);
-        read(fd, buf, 256);
+        auto readed_size = read(fd, buf, 256);
+        ASSERT_NE(readed_size, -1);
         close(fd);
         ASSERT_STREQ("hello world", buf);
         unlink("././body_sink_test_file_sink");
diff --git a/be/test/olap/bit_field_test.cpp b/be/test/olap/bit_field_test.cpp
index bedf8c4..a45a612 100644
--- a/be/test/olap/bit_field_test.cpp
+++ b/be/test/olap/bit_field_test.cpp
@@ -33,8 +33,8 @@ public:
     virtual ~TestBitField() {}
 
     void SetUp() {
-        system("mkdir -p ./ut_dir/");
-        system("rm ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir/"), 0);
+        ASSERT_EQ(system("rm ./ut_dir/tmp_file"), 0);
         _out_stream = new (std::nothrow) 
OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, nullptr);
         ASSERT_TRUE(_out_stream != nullptr);
         _writer = new (std::nothrow) BitFieldWriter(_out_stream);
diff --git a/be/test/olap/column_reader_test.cpp 
b/be/test/olap/column_reader_test.cpp
index 1b9c641..6647a6a 100644
--- a/be/test/olap/column_reader_test.cpp
+++ b/be/test/olap/column_reader_test.cpp
@@ -105,8 +105,8 @@ public:
 
         ASSERT_TRUE(_column_reader != nullptr);
 
-        system("mkdir -p ./ut_dir");
-        system("rm ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir"), 0);
+        ASSERT_EQ(system("rm ./ut_dir/tmp_file"), 0);
 
         ASSERT_EQ(OLAP_SUCCESS,
                   helper.open_with_mode("./ut_dir/tmp_file", O_CREAT | O_EXCL 
| O_WRONLY,
diff --git a/be/test/olap/delete_handler_test.cpp 
b/be/test/olap/delete_handler_test.cpp
index 09d4ad1..ee63658 100644
--- a/be/test/olap/delete_handler_test.cpp
+++ b/be/test/olap/delete_handler_test.cpp
@@ -47,7 +47,7 @@ static StorageEngine* k_engine = nullptr;
 
 void set_up() {
     char buffer[MAX_PATH_LEN];
-    getcwd(buffer, MAX_PATH_LEN);
+    ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
     config::storage_root_path = string(buffer) + "/data_test";
     FileUtils::remove_all(config::storage_root_path);
     FileUtils::remove_all(string(getenv("DORIS_HOME")) + UNUSED_PREFIX);
@@ -67,7 +67,7 @@ void set_up() {
 
 void tear_down() {
     char buffer[MAX_PATH_LEN];
-    getcwd(buffer, MAX_PATH_LEN);
+    ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
     config::storage_root_path = string(buffer) + "/data_test";
     FileUtils::remove_all(config::storage_root_path);
     FileUtils::remove_all(string(getenv("DORIS_HOME")) + UNUSED_PREFIX);
@@ -244,7 +244,7 @@ protected:
     void SetUp() {
         // Create local data dir for StorageEngine.
         char buffer[MAX_PATH_LEN];
-        getcwd(buffer, MAX_PATH_LEN);
+        ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
         config::storage_root_path = string(buffer) + "/data_delete_condition";
         FileUtils::remove_all(config::storage_root_path);
         ASSERT_TRUE(FileUtils::create_dir(config::storage_root_path).ok());
@@ -257,7 +257,7 @@ protected:
         ASSERT_EQ(OLAP_SUCCESS, res);
         tablet = 
k_engine->tablet_manager()->get_tablet(_create_tablet.tablet_id,
                                                         
_create_tablet.tablet_schema.schema_hash);
-        ASSERT_TRUE(tablet.get() != NULL);
+        ASSERT_NE(tablet.get(), nullptr);
         _tablet_path = tablet->tablet_path_desc().filepath;
 
         set_create_duplicate_tablet_request(&_create_dup_tablet);
@@ -415,7 +415,7 @@ protected:
     void SetUp() {
         // Create local data dir for StorageEngine.
         char buffer[MAX_PATH_LEN];
-        getcwd(buffer, MAX_PATH_LEN);
+        ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
         config::storage_root_path = string(buffer) + "/data_delete_condition";
         FileUtils::remove_all(config::storage_root_path);
         ASSERT_TRUE(FileUtils::create_dir(config::storage_root_path).ok());
@@ -782,7 +782,7 @@ protected:
         CpuInfo::init();
         // Create local data dir for StorageEngine.
         char buffer[MAX_PATH_LEN];
-        getcwd(buffer, MAX_PATH_LEN);
+        ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
         config::storage_root_path = string(buffer) + "/data_delete_condition";
         FileUtils::remove_all(config::storage_root_path);
         ASSERT_TRUE(FileUtils::create_dir(config::storage_root_path).ok());
diff --git a/be/test/olap/delta_writer_test.cpp 
b/be/test/olap/delta_writer_test.cpp
index f35a612..1e2cab2 100644
--- a/be/test/olap/delta_writer_test.cpp
+++ b/be/test/olap/delta_writer_test.cpp
@@ -51,7 +51,7 @@ std::shared_ptr<MemTracker> k_mem_tracker = nullptr;
 
 void set_up() {
     char buffer[MAX_PATH_LEN];
-    getcwd(buffer, MAX_PATH_LEN);
+    ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
     config::storage_root_path = std::string(buffer) + "/data_test";
     FileUtils::remove_all(config::storage_root_path);
     FileUtils::create_dir(config::storage_root_path);
@@ -75,7 +75,7 @@ void tear_down() {
         delete k_engine;
         k_engine = nullptr;
     }
-    system("rm -rf ./data_test");
+    ASSERT_EQ(system("rm -rf ./data_test"), 0);
     FileUtils::remove_all(std::string(getenv("DORIS_HOME")) + UNUSED_PREFIX);
 }
 
@@ -366,8 +366,7 @@ TEST_F(TestDeltaWriter, open) {
     PUniqueId load_id;
     load_id.set_hi(0);
     load_id.set_lo(0);
-    WriteRequest write_req = {10003, 270068375, WriteType::LOAD, 20001,
-                              30001, load_id, tuple_desc};
+    WriteRequest write_req = {10003, 270068375, WriteType::LOAD, 20001, 30001, 
load_id, tuple_desc};
     DeltaWriter* delta_writer = nullptr;
     DeltaWriter::open(&write_req, k_mem_tracker, &delta_writer);
     ASSERT_NE(delta_writer, nullptr);
@@ -400,8 +399,8 @@ TEST_F(TestDeltaWriter, write) {
     PUniqueId load_id;
     load_id.set_hi(0);
     load_id.set_lo(0);
-    WriteRequest write_req = {10004, 270068376,  WriteType::LOAD,       20002, 
30002, load_id,
-                              tuple_desc, &(tuple_desc->slots())};
+    WriteRequest write_req = {10004, 270068376, WriteType::LOAD, 20002,
+                              30002, load_id,   tuple_desc,      
&(tuple_desc->slots())};
     DeltaWriter* delta_writer = nullptr;
     DeltaWriter::open(&write_req, k_mem_tracker, &delta_writer);
     ASSERT_NE(delta_writer, nullptr);
@@ -526,8 +525,8 @@ TEST_F(TestDeltaWriter, sequence_col) {
     PUniqueId load_id;
     load_id.set_hi(0);
     load_id.set_lo(0);
-    WriteRequest write_req = {10005, 270068377,  WriteType::LOAD,       20003, 
30003, load_id,
-                              tuple_desc, &(tuple_desc->slots())};
+    WriteRequest write_req = {10005, 270068377, WriteType::LOAD, 20003,
+                              30003, load_id,   tuple_desc,      
&(tuple_desc->slots())};
     DeltaWriter* delta_writer = nullptr;
     DeltaWriter::open(&write_req, k_mem_tracker, &delta_writer);
     ASSERT_NE(delta_writer, nullptr);
diff --git a/be/test/olap/options_test.cpp b/be/test/olap/options_test.cpp
index 78d88f8..19509d2 100644
--- a/be/test/olap/options_test.cpp
+++ b/be/test/olap/options_test.cpp
@@ -18,19 +18,19 @@
 #include "olap/options.h"
 
 #include <gtest/gtest.h>
-#include <filesystem>
 
+#include <filesystem>
 #include <string>
 
 namespace doris {
 
 void set_up() {
-    system("rm -rf ./test_run && mkdir -p ./test_run");
-    system("mkdir -p ./test_run/palo && mkdir -p ./test_run/palo.ssd");
+    ASSERT_EQ(system("rm -rf ./test_run && mkdir -p ./test_run"), 0);
+    ASSERT_EQ(system("mkdir -p ./test_run/palo && mkdir -p 
./test_run/palo.ssd"), 0);
 }
 
 void tear_down() {
-    system("rm -rf ./test_run");
+    ASSERT_EQ(system("rm -rf ./test_run"), 0);
 }
 
 class OptionsTest : public testing::Test {
diff --git a/be/test/olap/rowset/alpha_rowset_test.cpp 
b/be/test/olap/rowset/alpha_rowset_test.cpp
index 609a9a7..bfa1982 100644
--- a/be/test/olap/rowset/alpha_rowset_test.cpp
+++ b/be/test/olap/rowset/alpha_rowset_test.cpp
@@ -52,7 +52,7 @@ static const uint32_t MAX_PATH_LEN = 1024;
 void set_up() {
     config::path_gc_check = false;
     char buffer[MAX_PATH_LEN];
-    getcwd(buffer, MAX_PATH_LEN);
+    ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
     config::storage_root_path = std::string(buffer) + "/data_test";
     FileUtils::remove_all(config::storage_root_path);
     ASSERT_TRUE(FileUtils::create_dir(config::storage_root_path).ok());
diff --git a/be/test/olap/rowset/beta_rowset_test.cpp 
b/be/test/olap/rowset/beta_rowset_test.cpp
index c3b11ef..350c65d 100644
--- a/be/test/olap/rowset/beta_rowset_test.cpp
+++ b/be/test/olap/rowset/beta_rowset_test.cpp
@@ -52,8 +52,9 @@ protected:
         config::tablet_map_shard_size = 1;
         config::txn_map_shard_size = 1;
         config::txn_shard_size = 1;
+
         char buffer[MAX_PATH_LEN];
-        getcwd(buffer, MAX_PATH_LEN);
+        ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
         config::storage_root_path = std::string(buffer) + "/data_test";
 
         ASSERT_TRUE(FileUtils::remove_all(config::storage_root_path).ok());
diff --git a/be/test/olap/rowset/rowset_converter_test.cpp 
b/be/test/olap/rowset/rowset_converter_test.cpp
index 0d991b3..2c0bf93 100644
--- a/be/test/olap/rowset/rowset_converter_test.cpp
+++ b/be/test/olap/rowset/rowset_converter_test.cpp
@@ -157,7 +157,7 @@ public:
         config::txn_shard_size = 1;
         config::path_gc_check = false;
         char buffer[MAX_PATH_LEN];
-        getcwd(buffer, MAX_PATH_LEN);
+        ASSERT_NE(getcwd(buffer, MAX_PATH_LEN), nullptr);
         config::storage_root_path = std::string(buffer) + "/data_test";
         FileUtils::remove_all(config::storage_root_path);
         ASSERT_TRUE(FileUtils::create_dir(config::storage_root_path).ok());
diff --git a/be/test/olap/run_length_byte_test.cpp 
b/be/test/olap/run_length_byte_test.cpp
index af12a44..d8e02bb 100644
--- a/be/test/olap/run_length_byte_test.cpp
+++ b/be/test/olap/run_length_byte_test.cpp
@@ -656,8 +656,8 @@ public:
     virtual ~TestRunLengthByte() {}
 
     virtual void SetUp() {
-        system("mkdir -p ./ut_dir");
-        system("rm -rf ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir"), 0);
+        ASSERT_EQ(system("rm -rf ./ut_dir/tmp_file"), 0);
         _out_stream = new (std::nothrow) 
OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, nullptr);
         ASSERT_TRUE(_out_stream != nullptr);
         _writer = new (std::nothrow) RunLengthByteWriter(_out_stream);
diff --git a/be/test/olap/run_length_integer_test.cpp 
b/be/test/olap/run_length_integer_test.cpp
index 0c8f712..0f4d49a 100644
--- a/be/test/olap/run_length_integer_test.cpp
+++ b/be/test/olap/run_length_integer_test.cpp
@@ -35,8 +35,8 @@ public:
     virtual ~TestRunLengthUnsignInteger() {}
 
     virtual void SetUp() {
-        system("mkdir -p ./ut_dir");
-        system("rm -rf ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir"), 0);
+        ASSERT_EQ(system("rm -rf ./ut_dir/tmp_file"), 0);
         _out_stream = new (std::nothrow) 
OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, nullptr);
         ASSERT_TRUE(_out_stream != nullptr);
         _writer = new (std::nothrow) RunLengthIntegerWriter(_out_stream, 
false);
@@ -340,8 +340,8 @@ public:
     virtual ~TestRunLengthSignInteger() {}
 
     virtual void SetUp() {
-        system("mkdir -p ./ut_dir");
-        system("rm ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir"), 0);
+        ASSERT_EQ(system("rm ./ut_dir/tmp_file"), 0);
         _out_stream = new (std::nothrow) 
OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, nullptr);
         ASSERT_TRUE(_out_stream != nullptr);
         _writer = new (std::nothrow) RunLengthIntegerWriter(_out_stream, true);
diff --git a/be/test/olap/schema_change_test.cpp 
b/be/test/olap/schema_change_test.cpp
index f71857a..7acc6ed 100644
--- a/be/test/olap/schema_change_test.cpp
+++ b/be/test/olap/schema_change_test.cpp
@@ -109,8 +109,8 @@ public:
 
         ASSERT_TRUE(_column_reader != nullptr);
 
-        system("mkdir -p ./ut_dir");
-        system("rm ./ut_dir/tmp_file");
+        ASSERT_EQ(system("mkdir -p ./ut_dir"), 0);
+        ASSERT_EQ(system("rm ./ut_dir/tmp_file"), 0);
 
         ASSERT_EQ(OLAP_SUCCESS,
                   helper.open_with_mode("./ut_dir/tmp_file", O_CREAT | O_EXCL 
| O_WRONLY,
@@ -532,7 +532,8 @@ TEST_F(TestColumn, ConvertVarcharToDate) {
         _col_vector.reset(new ColumnVector());
         ASSERT_EQ(_column_reader->next_vector(_col_vector.get(), 1, 
_mem_pool.get()), OLAP_SUCCESS);
         char* data = reinterpret_cast<char*>(_col_vector->col_data());
-        read_row.convert_from(0, data, 
write_row.column_schema(0)->type_info().get(), _mem_pool.get());
+        read_row.convert_from(0, data, 
write_row.column_schema(0)->type_info().get(),
+                              _mem_pool.get());
         std::string dst_str = 
read_row.column_schema(0)->to_string(read_row.cell_ptr(0));
         ASSERT_EQ(expected_val, dst_str);
     }
diff --git a/be/test/runtime/memory_scratch_sink_test.cpp 
b/be/test/runtime/memory_scratch_sink_test.cpp
index b2443ac..05127f4 100644
--- a/be/test/runtime/memory_scratch_sink_test.cpp
+++ b/be/test/runtime/memory_scratch_sink_test.cpp
@@ -71,16 +71,16 @@ public:
         config::periodic_counter_update_period_ms = 500;
         config::storage_root_path = "./data";
 
-        system("mkdir -p ./test_run/output/");
-        system("pwd");
-        system("cp -r ./be/test/runtime/test_data/ ./test_run/.");
+        ASSERT_EQ(system("mkdir -p ./test_run/output/"), 0);
+        ASSERT_EQ(system("pwd"), 0);
+        ASSERT_EQ(system("cp -r ./be/test/runtime/test_data/ ./test_run/."), 
0);
 
         init();
     }
 
     virtual void TearDown() {
         _obj_pool.clear();
-        system("rm -rf ./test_run");
+        ASSERT_EQ(system("rm -rf ./test_run"), 0);
     }
 
     void init();
diff --git a/be/test/runtime/user_function_cache_test.cpp 
b/be/test/runtime/user_function_cache_test.cpp
index 201e8cb..96767e5 100644
--- a/be/test/runtime/user_function_cache_test.cpp
+++ b/be/test/runtime/user_function_cache_test.cpp
@@ -96,15 +96,18 @@ public:
         hostname = "http://127.0.0.1:"; + std::to_string(real_port);
 
         // compile code to so
-        system("g++ -shared -fPIC 
./be/test/runtime/test_data/user_function_cache/lib/my_add.cc -o "
-               
"./be/test/runtime/test_data/user_function_cache/lib/my_add.so");
+        ASSERT_EQ(system("g++ -shared -fPIC "
+                         
"./be/test/runtime/test_data/user_function_cache/lib/my_add.cc -o "
+                         
"./be/test/runtime/test_data/user_function_cache/lib/my_add.so"),
+                  0);
 
         my_add_md5sum =
                 
compute_md5("./be/test/runtime/test_data/user_function_cache/lib/my_add.so");
     }
     static void TearDownTestCase() {
         delete s_server;
-        system("rm -rf 
./be/test/runtime/test_data/user_function_cache/lib/my_add.so");
+        ASSERT_EQ(system("rm -rf 
./be/test/runtime/test_data/user_function_cache/lib/my_add.so"),
+                  0);
     }
     void SetUp() override { k_is_downloaded = false; }
 };
diff --git a/be/test/util/arrow/arrow_work_flow_test.cpp 
b/be/test/util/arrow/arrow_work_flow_test.cpp
index 658a5ac..7930589 100644
--- a/be/test/util/arrow/arrow_work_flow_test.cpp
+++ b/be/test/util/arrow/arrow_work_flow_test.cpp
@@ -54,15 +54,15 @@ protected:
         config::periodic_counter_update_period_ms = 500;
         config::storage_root_path = "./data";
 
-        system("mkdir -p ./test_run/output/");
-        system("pwd");
-        system("cp -r ./be/test/util/test_data/ ./test_run/.");
+        ASSERT_EQ(system("mkdir -p ./test_run/output/"), 0);
+        ASSERT_EQ(system("pwd"), 0);
+        ASSERT_EQ(system("cp -r ./be/test/util/test_data/ ./test_run/."), 0);
 
         init();
     }
     virtual void TearDown() {
         _obj_pool.clear();
-        system("rm -rf ./test_run");
+        ASSERT_EQ(system("rm -rf ./test_run"), 0);
 
         delete _state;
     }
diff --git a/be/test/vec/function/CMakeLists.txt 
b/be/test/vec/function/CMakeLists.txt
index 6ae9b05..c4101f5 100644
--- a/be/test/vec/function/CMakeLists.txt
+++ b/be/test/vec/function/CMakeLists.txt
@@ -28,3 +28,4 @@ ADD_BE_TEST(function_ifnull_test)
 ADD_BE_TEST(function_nullif_test)
 ADD_BE_TEST(function_like_test)
 ADD_BE_TEST(function_arithmetic_test)
+ADD_BE_TEST(function_json_test)
diff --git a/be/test/vec/function/function_json_test.cpp 
b/be/test/vec/function/function_json_test.cpp
new file mode 100644
index 0000000..acb3fb9
--- /dev/null
+++ b/be/test/vec/function/function_json_test.cpp
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest.h>
+
+#include "function_test_util.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+using namespace ut_type;
+
+TEST(FunctionJsonTEST, GetJsonDoubleTest) {
+    std::string func_name = "get_json_double";
+    InputTypeSet input_types = {TypeIndex::String, TypeIndex::String};
+    DataSet data_set = {
+            {{VARCHAR("{\"k1\":1.3, \"k2\":2}"), VARCHAR("$.k1")}, 
DOUBLE(1.3)},
+            {{VARCHAR("{\"k1\":\"v1\", \"my.key\":[1.1, 2.2, 3.3]}"), 
VARCHAR("$.\"my.key\"[1]")},
+             DOUBLE(2.2)},
+            {{VARCHAR("{\"k1.key\":{\"k2\":[1.1, 2.2]}}"), 
VARCHAR("$.\"k1.key\".k2[0]")},
+             DOUBLE(1.1)}};
+
+    check_function<DataTypeFloat64, true>(func_name, input_types, data_set);
+}
+
+TEST(FunctionJsonTEST, GetJsonIntTest) {
+    std::string func_name = "get_json_int";
+    InputTypeSet input_types = {TypeIndex::String, TypeIndex::String};
+    DataSet data_set = {
+            {{VARCHAR("{\"k1\":1, \"k2\":2}"), VARCHAR("$.k1")}, INT(1)},
+            {{VARCHAR("{\"k1\":\"v1\", \"my.key\":[1, 2, 3]}"), 
VARCHAR("$.\"my.key\"[1]")},
+             INT(2)},
+            {{VARCHAR("{\"k1.key\":{\"k2\":[1, 2]}}"), 
VARCHAR("$.\"k1.key\".k2[0]")}, INT(1)}};
+
+    check_function<DataTypeInt32, true>(func_name, input_types, data_set);
+}
+
+TEST(FunctionJsonTEST, GetJsonStringTest) {
+    std::string func_name = "get_json_string";
+    InputTypeSet input_types = {TypeIndex::String, TypeIndex::String};
+    DataSet data_set = {
+            {{VARCHAR("{\"k1\":\"v1\", \"k2\":\"v2\"}"), VARCHAR("$.k1")}, 
VARCHAR("v1")},
+            {{VARCHAR("{\"k1\":\"v1\", \"my.key\":[\"e1\", \"e2\", \"e3\"]}"),
+              VARCHAR("$.\"my.key\"[1]")},
+             VARCHAR("e2")},
+            {{VARCHAR("{\"k1.key\":{\"k2\":[\"v1\", \"v2\"]}}"), 
VARCHAR("$.\"k1.key\".k2[0]")},
+             VARCHAR("v1")},
+            {{VARCHAR("[{\"k1\":\"v1\"}, {\"k2\":\"v2\"}, {\"k1\":\"v3\"}, 
{\"k1\":\"v4\"}]"),
+              VARCHAR("$.k1")},
+             VARCHAR("[\"v1\",\"v3\",\"v4\"]")}};
+
+    check_function<DataTypeString, true>(func_name, input_types, data_set);
+}
+
+} // namespace doris::vectorized
+
+int main(int argc, char** argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}
diff --git a/build.sh b/build.sh
index ed00c5c..8eb06c0 100755
--- a/build.sh
+++ b/build.sh
@@ -199,8 +199,8 @@ fi
 if [[ -z ${BUILD_META_TOOL} ]]; then
     BUILD_META_TOOL=ON
 fi
-if [[ -z ${USE_LDD} ]]; then
-    USE_LDD=OFF
+if [[ -z ${USE_LLD} ]]; then
+    USE_LLD=OFF
 fi
 
 echo "Get params:
@@ -217,7 +217,7 @@ echo "Get params:
     USE_AVX2            -- $USE_AVX2
     USE_LIBCPP          -- $USE_LIBCPP
     BUILD_META_TOOL     -- $BUILD_META_TOOL
-    USE_LDD             -- $USE_LDD
+    USE_LLD             -- $USE_LLD
 "
 
 # Clean and build generated code
@@ -252,7 +252,7 @@ if [ ${BUILD_BE} -eq 1 ] ; then
             -DWITH_LZO=${WITH_LZO} \
             -DUSE_LIBCPP=${USE_LIBCPP} \
             -DBUILD_META_TOOL=${BUILD_META_TOOL} \
-            -DUSE_LDD=${USE_LDD} \
+            -DUSE_LLD=${USE_LLD} \
             -DUSE_AVX2=${USE_AVX2} \
             -DGLIBC_COMPATIBILITY=${GLIBC_COMPATIBILITY} ../
     ${BUILD_SYSTEM} -j ${PARALLEL}
diff --git a/run-be-ut.sh b/run-be-ut.sh
index 7bd59e0..85b2fc8 100755
--- a/run-be-ut.sh
+++ b/run-be-ut.sh
@@ -76,6 +76,10 @@ eval set -- "$OPTS"
 
 PARALLEL=$[$(nproc)/5+1]
 
+if [[ -z ${USE_LLD} ]]; then
+    USE_LLD=OFF
+fi
+
 CLEAN=0
 RUN=0
 VECTORIZED_ONLY=0
@@ -133,6 +137,7 @@ ${CMAKE_CMD} -G "${GENERATOR}" \
     -DCMAKE_MAKE_PROGRAM="${MAKE_PROGRAM}" \
     -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
     -DMAKE_TEST=ON \
+    -DUSE_LLD=${USE_LLD} \
     -DGLIBC_COMPATIBILITY="${GLIBC_COMPATIBILITY}" \
     -DBUILD_META_TOOL=OFF \
     -DWITH_MYSQL=OFF \

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

Reply via email to