Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions be/src/util/jsonb_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,10 @@ inline bool JsonbPath::parsePath(Stream* stream, JsonbPath* path) {
// advance past the .
stream->skip(1);

if (stream->exhausted()) {
return false;
}

// $.[0]
if (stream->peek() == BEGIN_ARRAY) {
return parse_array(stream, path);
Expand All @@ -1523,6 +1527,10 @@ inline bool JsonbPath::parse_array(Stream* stream, JsonbPath* path) {
stream->set_leg_ptr(const_cast<char*>(stream->position()));
stream->add_leg_len();
stream->skip(1);
if (stream->exhausted()) {
return false;
}

if (stream->peek() == END_ARRAY) {
std::unique_ptr<leg_info> leg(
new leg_info(stream->get_leg_ptr(), stream->get_leg_len(), 0, ARRAY_CODE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,26 @@ suite("test_json_parse") {
check_fold_consistency "json_parse_error_to_null('null')"
check_fold_consistency "json_parse_error_to_null('123')"
check_fold_consistency "json_parse_error_to_null('[1, 2, 3]')"


sql """DROP TABLE IF EXISTS `test_invalid_path_tbl`;"""
sql """
CREATE TABLE `test_invalid_path_tbl` (
`id` int NULL,
`v` json NULL,
`s` text NULL
) ENGINE=OLAP
DUPLICATE KEY(`id`)
DISTRIBUTED BY RANDOM BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1");
"""

sql """ insert into test_invalid_path_tbl values (1, '{"key": "value"}', '\$.\$.'); """

test {
sql "SELECT id, json_exists_path(v, s) FROM test_invalid_path_tbl;"
exception "Json path error: Invalid Json Path for value: \$.\$."
}
}

Loading