This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new d085030dd2f [Exception](Json functions) throw Exception when using
escaped_list_separator #32808 (#35172)
d085030dd2f is described below
commit d085030dd2f648ad99c8009a95efe17961bae93f
Author: lihangyu <[email protected]>
AuthorDate: Tue May 28 15:05:35 2024 +0800
[Exception](Json functions) throw Exception when using
escaped_list_separator #32808 (#35172)
---
be/src/exprs/json_functions.cpp | 13 +++++++++----
be/src/util/string_util.h | 11 +++++++++--
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/be/src/exprs/json_functions.cpp b/be/src/exprs/json_functions.cpp
index 8612432b160..8fd5c2b0c4e 100644
--- a/be/src/exprs/json_functions.cpp
+++ b/be/src/exprs/json_functions.cpp
@@ -34,6 +34,7 @@
// IWYU pragma: no_include <opentelemetry/common/threadlocal.h>
#include "common/compiler_util.h" // IWYU pragma: keep
+#include "common/exception.h"
#include "common/logging.h"
namespace doris {
@@ -212,10 +213,14 @@ void JsonFunctions::parse_json_paths(const std::string&
path_string,
// '$.text#abc.xyz' -> [$, text#abc, xyz]
// '$."text.abc".xyz' -> [$, text.abc, xyz]
// '$."text.abc"[1].xyz' -> [$, text.abc[1], xyz]
- boost::tokenizer<boost::escaped_list_separator<char>> tok(
- path_string, boost::escaped_list_separator<char>("\\", ".", "\""));
- std::vector<std::string> paths(tok.begin(), tok.end());
- get_parsed_paths(paths, parsed_paths);
+ try {
+ boost::tokenizer<boost::escaped_list_separator<char>> tok(
+ path_string, boost::escaped_list_separator<char>("\\", ".",
"\""));
+ std::vector<std::string> paths(tok.begin(), tok.end());
+ get_parsed_paths(paths, parsed_paths);
+ } catch (boost::escaped_list_error err) {
+ throw doris::Exception(ErrorCode::INVALID_JSON_PATH, "meet error {}",
err.what());
+ }
}
void JsonFunctions::get_parsed_paths(const std::vector<std::string>&
path_exprs,
diff --git a/be/src/util/string_util.h b/be/src/util/string_util.h
index c118e5ddab7..06d6d1edccf 100644
--- a/be/src/util/string_util.h
+++ b/be/src/util/string_util.h
@@ -32,6 +32,9 @@
#include <unordered_set>
#include <vector>
+#include "common/exception.h"
+#include "common/status.h"
+
namespace doris {
inline std::string to_lower(const std::string& input) {
@@ -135,8 +138,12 @@ using StringCaseUnorderedMap =
template <typename T>
auto get_json_token(T& path_string) {
- return boost::tokenizer<boost::escaped_list_separator<char>>(
- path_string, boost::escaped_list_separator<char>("\\", ".", "\""));
+ try {
+ return boost::tokenizer<boost::escaped_list_separator<char>>(
+ path_string, boost::escaped_list_separator<char>("\\", ".",
"\""));
+ } catch (boost::escaped_list_error err) {
+ throw doris::Exception(ErrorCode::INVALID_JSON_PATH, "meet error {}",
err.what());
+ }
}
#ifdef USE_LIBCPP
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]