This is an automated email from the ASF dual-hosted git repository. yiguolei 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 291fa499e9 [fix](JSON) Fail to parse JSONPath (libc++) (#13941) 291fa499e9 is described below commit 291fa499e910b5c271262c53f9edc66b6a23a0ab Author: Adonis Ling <adonis0...@gmail.com> AuthorDate: Wed Nov 9 08:58:01 2022 +0800 [fix](JSON) Fail to parse JSONPath (libc++) (#13941) --- be/src/exprs/json_functions.cpp | 12 +++++++++--- be/src/exprs/json_functions.h | 5 ++--- be/src/util/string_util.h | 13 +++++++------ be/src/vec/functions/function_json.cpp | 8 ++++++-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/be/src/exprs/json_functions.cpp b/be/src/exprs/json_functions.cpp index b449ffceaf..98756a4d8b 100644 --- a/be/src/exprs/json_functions.cpp +++ b/be/src/exprs/json_functions.cpp @@ -299,8 +299,8 @@ rapidjson::Value* JsonFunctions::match_value(const std::vector<JsonPath>& parsed } rapidjson::Value* JsonFunctions::get_json_object(FunctionContext* context, - const std::string_view& json_string, - const std::string_view& path_string, + std::string_view json_string, + std::string_view path_string, const JsonFunctionType& fntype, rapidjson::Document* document) { // split path by ".", and escape quota by "\" @@ -319,13 +319,19 @@ rapidjson::Value* JsonFunctions::get_json_object(FunctionContext* context, } if (json_state->json_paths.size() == 0) { +#ifdef USE_LIBCPP + std::string s(path_string); + auto tok = get_json_token(s); +#else auto tok = get_json_token(path_string); +#endif std::vector<std::string> paths(tok.begin(), tok.end()); get_parsed_paths(paths, &json_state->json_paths); } #else json_state = &tmp_json_state; - auto tok = get_json_token(path_string); + std::string s(path_string); + auto tok = get_json_token(s); std::vector<std::string> paths(tok.begin(), tok.end()); get_parsed_paths(paths, &json_state->json_paths); #endif diff --git a/be/src/exprs/json_functions.h b/be/src/exprs/json_functions.h index f976c5ec00..89899271a8 100644 --- a/be/src/exprs/json_functions.h +++ b/be/src/exprs/json_functions.h @@ -108,9 +108,8 @@ public: const doris_udf::StringVal& json_str, const doris_udf::StringVal& path); - static rapidjson::Value* get_json_object(FunctionContext* context, - const std::string_view& json_string, - const std::string_view& path_string, + static rapidjson::Value* get_json_object(FunctionContext* context, std::string_view json_string, + std::string_view path_string, const JsonFunctionType& fntype, rapidjson::Document* document); diff --git a/be/src/util/string_util.h b/be/src/util/string_util.h index 7fce0a8500..0d2fe7e3ee 100644 --- a/be/src/util/string_util.h +++ b/be/src/util/string_util.h @@ -130,14 +130,15 @@ template <class T> using StringCaseUnorderedMap = std::unordered_map<std::string, T, StringCaseHasher, StringCaseEqual>; -inline auto get_json_token(const std::string_view& path_string) { -#ifdef USE_LIBCPP - return boost::tokenizer<boost::escaped_list_separator<char>>( - std::string(path_string), boost::escaped_list_separator<char>("\\", ".", "\"")); -#else +template <typename T> +inline auto get_json_token(T& path_string) { return boost::tokenizer<boost::escaped_list_separator<char>>( path_string, boost::escaped_list_separator<char>("\\", ".", "\"")); -#endif } +#ifdef USE_LIBCPP +template <> +inline auto get_json_token(std::string_view& path_string) = delete; +#endif + } // namespace doris diff --git a/be/src/vec/functions/function_json.cpp b/be/src/vec/functions/function_json.cpp index 55184997a3..d04390be95 100644 --- a/be/src/vec/functions/function_json.cpp +++ b/be/src/vec/functions/function_json.cpp @@ -187,13 +187,17 @@ rapidjson::Value* match_value(const std::vector<JsonPath>& parsed_paths, rapidjs } template <JsonFunctionType fntype> -rapidjson::Value* get_json_object(const std::string_view& json_string, - const std::string_view& path_string, +rapidjson::Value* get_json_object(std::string_view json_string, std::string_view path_string, rapidjson::Document* document) { std::vector<JsonPath>* parsed_paths; std::vector<JsonPath> tmp_parsed_paths; +#ifdef USE_LIBCPP + std::string s(path_string); + auto tok = get_json_token(s); +#else auto tok = get_json_token(path_string); +#endif std::vector<std::string> paths(tok.begin(), tok.end()); get_parsed_paths(paths, &tmp_parsed_paths); parsed_paths = &tmp_parsed_paths; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org