LemonLiTree commented on code in PR #19646:
URL: https://github.com/apache/doris/pull/19646#discussion_r1208908840
##########
be/src/util/jsonb_document.h:
##########
@@ -1200,52 +1225,125 @@ inline JsonbValue* JsonbValue::findPath(const char*
key_path, unsigned int kp_le
stream.clear_legPtr();
stream.clear_legLen();
- if (!JsonbPath::parsePath(&stream, pval)) {
+ if (!JsonbPath::parsePath(&stream)) {
+ is_invalid_json_path = stream.get_is_invalid_json_path();
return nullptr;
}
if (stream.get_legLen() == 0) {
return nullptr;
}
- if (LIKELY(pval->type_ == JsonbType::T_Object)) {
- if (stream.get_legLen() == 1 && *stream.get_legPtr() == WILDCARD) {
- return pval;
- } else if (stream.get_hasEscapes()) {
- stream.remove_escapes();
- }
+ if (stream.get_type() == MEMBER_CODE) {
+ if (LIKELY(pval->type_ == JsonbType::T_Array)) {
+ return nullptr;
+ } else if (LIKELY(pval->type_ == JsonbType::T_Object)) {
+ if (stream.get_legLen() == 1 && *stream.get_legPtr() ==
WILDCARD) {
+ continue;
+ } else if (stream.get_hasEscapes()) {
+ stream.remove_escapes();
+ }
- pval = ((ObjectVal*)pval)->find(stream.get_legPtr(),
stream.get_legLen(), handler);
+ pval = ((ObjectVal*)pval)->find(stream.get_legPtr(),
stream.get_legLen(), handler);
- if (!pval) return nullptr;
- } else if (LIKELY(pval->type_ == JsonbType::T_Array)) {
+ if (!pval) return nullptr;
+ } else {
+ return nullptr;
+ }
+ } else if (stream.get_type() == ARRAY_CODE) {
int index = 0;
- std::string idx_string(stream.get_legPtr(), stream.get_legLen());
+ std::string_view idx_string(stream.get_legPtr(),
stream.get_legLen());
if (stream.get_legLen() == 1 && *stream.get_legPtr() == WILDCARD) {
- return pval;
- } else if (std::string(stream.get_legPtr(), 4) == LAST) {
+ if (LIKELY(pval->type_ == JsonbType::T_Object)) {
+ return nullptr;
+ } else if (LIKELY(pval->type_ == JsonbType::T_Array)) {
+ continue;
Review Comment:
In order to support '$[*][0]', but should skip(1) and skip_whitespace()
before continue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]