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

gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 977404e5409 [fix](compile) Enable compile checking for function_json 
(#42329)
977404e5409 is described below

commit 977404e5409bd57b761676e04d38180dd0bdc7f2
Author: Gabriel <[email protected]>
AuthorDate: Thu Oct 24 09:47:29 2024 +0800

    [fix](compile) Enable compile checking for function_json (#42329)
---
 be/src/util/string_parser.hpp          |  4 ++--
 be/src/vec/functions/function_json.cpp | 35 ++++++++++++++++++++--------------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/be/src/util/string_parser.hpp b/be/src/util/string_parser.hpp
index a9cea7b8d29..67ab41cc1c7 100644
--- a/be/src/util/string_parser.hpp
+++ b/be/src/util/string_parser.hpp
@@ -102,7 +102,7 @@ public:
     // In the case of overflow, the max/min value for the data type will be 
returned.
     // Assumes s represents a decimal number.
     template <typename T>
-    static inline T string_to_int(const char* __restrict s, int len, 
ParseResult* result) {
+    static inline T string_to_int(const char* __restrict s, size_t len, 
ParseResult* result) {
         T ans = string_to_int_internal<T>(s, len, result);
         if (LIKELY(*result == PARSE_SUCCESS)) {
             return ans;
@@ -140,7 +140,7 @@ public:
     }
 
     template <typename T>
-    static inline T string_to_float(const char* __restrict s, int len, 
ParseResult* result) {
+    static inline T string_to_float(const char* __restrict s, size_t len, 
ParseResult* result) {
         return string_to_float_internal<T>(s, len, result);
     }
 
diff --git a/be/src/vec/functions/function_json.cpp 
b/be/src/vec/functions/function_json.cpp
index d6a704613b4..05915db8ec1 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -47,6 +47,7 @@
 #else
 #include "util/jsonb_parser.h"
 #endif
+#include "common/cast_set.h"
 #include "util/string_parser.hpp"
 #include "util/string_util.h"
 #include "vec/aggregate_functions/aggregate_function.h"
@@ -76,6 +77,7 @@ class FunctionContext;
 } // namespace doris
 
 namespace doris::vectorized {
+#include "common/compile_check_begin.h"
 static const re2::RE2 JSON_PATTERN("^([^\\\"\\[\\]]*)(?:\\[([0-9]+|\\*)\\])?");
 
 template <typename T, typename U>
@@ -257,7 +259,9 @@ rapidjson::Value* get_json_object(std::string_view 
json_string, std::string_view
 
     if (UNLIKELY((*parsed_paths).size() == 1)) {
         if (fntype == JSON_FUN_STRING) {
-            document->SetString(json_string.data(), json_string.size(), 
document->GetAllocator());
+            document->SetString(json_string.data(),
+                                
cast_set<rapidjson::SizeType>(json_string.size()),
+                                document->GetAllocator());
         } else {
             return document;
         }
@@ -375,7 +379,7 @@ struct GetJsonNumberType {
         } else if (root->IsInt()) {
             res = root->GetInt();
         } else if (root->IsInt64()) {
-            res = root->GetInt64();
+            res = static_cast<double>(root->GetInt64());
         } else if (root->IsDouble()) {
             res = root->GetDouble();
         } else {
@@ -547,7 +551,7 @@ struct JsonParser {
     //string
     static void update_value(StringParser::ParseResult& result, 
rapidjson::Value& value,
                              StringRef data, 
rapidjson::Document::AllocatorType& allocator) {
-        value.SetString(data.data, data.size, allocator);
+        value.SetString(data.data, cast_set<rapidjson::SizeType>(data.size), 
allocator);
     }
 };
 
@@ -595,7 +599,7 @@ struct JsonParser<'4'> {
     static void update_value(StringParser::ParseResult& result, 
rapidjson::Value& value,
                              StringRef data, 
rapidjson::Document::AllocatorType& allocator) {
         // remove double quotes, "xxx" -> xxx
-        value.SetString(data.data + 1, data.size - 2, allocator);
+        value.SetString(data.data + 1, cast_set<rapidjson::SizeType>(data.size 
- 2), allocator);
     }
 };
 
@@ -779,8 +783,8 @@ public:
         }
     }
 
-    static Status check_keys_all_not_null(const std::vector<const 
ColumnUInt8*>& nullmaps, int size,
-                                          size_t args) {
+    static Status check_keys_all_not_null(const std::vector<const 
ColumnUInt8*>& nullmaps,
+                                          size_t size, size_t args) {
         for (int i = 0; i < args; i += 2) {
             const auto* null_map = nullmaps[i];
             if (null_map) {
@@ -818,7 +822,7 @@ struct FunctionJsonQuoteImpl {
 
         for (int i = 0; i < input_rows_count; i++) {
             StringRef data = data_columns[0]->get_data_at(i);
-            value.SetString(data.data, data.size, allocator);
+            value.SetString(data.data, 
cast_set<rapidjson::SizeType>(data.size), allocator);
 
             buf.Clear();
             rapidjson::Writer<rapidjson::StringBuffer> writer(buf);
@@ -832,8 +836,9 @@ struct FunctionJsonExtractImpl {
     static constexpr auto name = "json_extract";
 
     static rapidjson::Value parse_json(const ColumnString* json_col, const 
ColumnString* path_col,
-                                       rapidjson::Document::AllocatorType& 
allocator, const int row,
-                                       const int col, std::vector<bool>& 
column_is_consts) {
+                                       rapidjson::Document::AllocatorType& 
allocator,
+                                       const size_t row, const size_t col,
+                                       std::vector<bool>& column_is_consts) {
         rapidjson::Value value;
         rapidjson::Document document;
 
@@ -850,7 +855,7 @@ struct FunctionJsonExtractImpl {
 
     static rapidjson::Value* get_document(const ColumnString* path_col,
                                           rapidjson::Document* document,
-                                          std::vector<JsonPath>& parsed_paths, 
const int row,
+                                          std::vector<JsonPath>& parsed_paths, 
const size_t row,
                                           bool is_const_column) {
         const auto path = path_col->get_data_at(index_check_const(row, 
is_const_column));
         std::string_view path_string(path.data, path.size);
@@ -886,7 +891,7 @@ struct FunctionJsonExtractImpl {
         rapidjson::StringBuffer buf;
         rapidjson::Writer<rapidjson::StringBuffer> writer(buf);
         const auto* json_col = data_columns[0];
-        auto insert_result_lambda = [&](rapidjson::Value& value, int row) {
+        auto insert_result_lambda = [&](rapidjson::Value& value, size_t row) {
             if (value.IsNull()) {
                 null_map[row] = 1;
                 result_column.insert_default();
@@ -909,7 +914,9 @@ struct FunctionJsonExtractImpl {
                         const auto& obj = json_col->get_data_at(row);
                         std::string_view json_string(obj.data, obj.size);
                         if (UNLIKELY((parsed_paths).size() == 1)) {
-                            document.SetString(json_string.data(), 
json_string.size(), allocator);
+                            document.SetString(json_string.data(),
+                                               
cast_set<rapidjson::SizeType>(json_string.size()),
+                                               allocator);
                         }
                         document.Parse(json_string.data(), json_string.size());
                         if (UNLIKELY(document.HasParseError())) {
@@ -938,7 +945,7 @@ struct FunctionJsonExtractImpl {
         } else {
             rapidjson::Value value;
             value.SetArray();
-            value.Reserve(data_columns.size() - 1, allocator);
+            value.Reserve(cast_set<rapidjson::SizeType>(data_columns.size() - 
1), allocator);
             for (size_t row = 0; row < input_rows_count; row++) {
                 value.Clear();
                 for (size_t col = 1; col < data_columns.size(); ++col) {
@@ -1073,7 +1080,7 @@ public:
             }
 
             const auto& val = col_from_string->get_data_at(i);
-            if (parser.parse(val.data, val.size)) {
+            if (parser.parse(val.data, cast_set<unsigned int>(val.size))) {
                 vec_to[i] = 1;
             } else {
                 vec_to[i] = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to