Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonLiTree committed Dec 8, 2023
1 parent 8526b9f commit 6b320f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions be/src/util/jsonb_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ inline bool JsonbPath::parse_member(Stream* stream, JsonbPath* path) {
stream->skip(1);
stream->add_leg_len();
stream->set_has_escapes(true);
if (stream->exhausted()) return false;
continue;
} else if (stream->peek() == DOUBLE_QUOTE) {
if (left_quotation_marks == nullptr) {
Expand Down
7 changes: 7 additions & 0 deletions be/src/vec/functions/function_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,19 @@ rapidjson::Value* get_json_object(std::string_view json_string, std::string_view
std::vector<JsonPath>* parsed_paths;
std::vector<JsonPath> tmp_parsed_paths;

//Cannot use '/' as the last character, return NULL
if(path_string.back() == '\\') {
document->SetNull();
return document;
}

#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);
if (tmp_parsed_paths.empty()) {
Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/json_p0/test_json_load_and_function.out
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
30 -9223372036854775808
31 18446744073709551615

-- !select --
\N

-- !select --
1 \N \N
2 null null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ suite("test_json_load_and_function", "p0") {
qt_select "SELECT * FROM ${testTable} ORDER BY id"

// json_extract
qt_select "SELECT json_extract( '{\"k1\\\\\": \"v1\"}', \"\$.k1\\\\\")"
qt_select "SELECT id, j, jsonb_extract(j, '\$') FROM ${testTable} ORDER BY id"
qt_select "SELECT id, j, jsonb_extract(j, '\$.*') FROM ${testTable} ORDER BY id"

Expand Down

0 comments on commit 6b320f3

Please sign in to comment.