[Pick](Branch-2.1) pick json reader fix and support specify $. as column (#39271)
#39206 #38213
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <re2/re2.h>
|
||||
#include <simdjson/error.h>
|
||||
#include <simdjson/simdjson.h> // IWYU pragma: keep
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -254,13 +255,17 @@ Status JsonFunctions::extract_from_object(simdjson::ondemand::object& obj,
|
||||
const std::vector<JsonPath>& jsonpath,
|
||||
simdjson::ondemand::value* value) noexcept {
|
||||
// Return DataQualityError when it's a malformed json.
|
||||
// Otherwise the path was not found, due to array out of bound or not exist
|
||||
// Otherwise the path was not found, due to
|
||||
// 1. array out of bound
|
||||
// 2. not exist such field in object
|
||||
// 3. the input type is not object but could be null or other types and lead to simdjson::INCORRECT_TYPE
|
||||
#define HANDLE_SIMDJSON_ERROR(err, msg) \
|
||||
do { \
|
||||
const simdjson::error_code& _err = err; \
|
||||
const std::string& _msg = msg; \
|
||||
if (UNLIKELY(_err)) { \
|
||||
if (_err == simdjson::NO_SUCH_FIELD || _err == simdjson::INDEX_OUT_OF_BOUNDS) { \
|
||||
if (_err == simdjson::NO_SUCH_FIELD || _err == simdjson::INDEX_OUT_OF_BOUNDS || \
|
||||
_err == simdjson::INCORRECT_TYPE) { \
|
||||
return Status::NotFound<false>( \
|
||||
fmt::format("Not found target filed, err: {}, msg: {}", \
|
||||
simdjson::error_message(_err), _msg)); \
|
||||
@ -348,4 +353,9 @@ void JsonFunctions::merge_objects(rapidjson::Value& dst_object, rapidjson::Value
|
||||
}
|
||||
}
|
||||
|
||||
// root path "$."
|
||||
bool JsonFunctions::is_root_path(const std::vector<JsonPath>& json_path) {
|
||||
return json_path.size() == 2 && json_path[0].key == "$" && json_path[1].key.empty();
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
|
||||
Reference in New Issue
Block a user