diff --git a/be/src/util/string_parser.hpp b/be/src/util/string_parser.hpp index a9cea7b8d29281..67ab41cc1c7bee 100644 --- a/be/src/util/string_parser.hpp +++ b/be/src/util/string_parser.hpp @@ -102,7 +102,7 @@ class StringParser { // In the case of overflow, the max/min value for the data type will be returned. // Assumes s represents a decimal number. template - 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(s, len, result); if (LIKELY(*result == PARSE_SUCCESS)) { return ans; @@ -140,7 +140,7 @@ class StringParser { } template - 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(s, len, result); } diff --git a/be/src/vec/functions/function_json.cpp b/be/src/vec/functions/function_json.cpp index d6a704613b404d..05915db8ec10bf 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 @@ -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(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(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(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(data.size - 2), allocator); } }; @@ -779,8 +783,8 @@ class FunctionJsonAlwaysNotNullable : public IFunction { } } - static Status check_keys_all_not_null(const std::vector& nullmaps, int size, - size_t args) { + static Status check_keys_all_not_null(const std::vector& 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(data.size), allocator); buf.Clear(); rapidjson::Writer 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& column_is_consts) { + rapidjson::Document::AllocatorType& allocator, + const size_t row, const size_t col, + std::vector& 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& parsed_paths, const int row, + std::vector& 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 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(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(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 @@ class FunctionJsonValid : public IFunction { } const auto& val = col_from_string->get_data_at(i); - if (parser.parse(val.data, val.size)) { + if (parser.parse(val.data, cast_set(val.size))) { vec_to[i] = 1; } else { vec_to[i] = 0;