mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-08-19 04:28:21 +00:00
f639a2099d
Expose JSON object key listing for outermost objects, with sqlness coverage.
148 lines
6.4 KiB
Plaintext
148 lines
6.4 KiB
Plaintext
--- json_object_keys ---
|
|
SELECT json_object_keys(parse_json('{"a": 1, "b": {"c": 2}}'));
|
|
|
|
+---------------------------------------------------------------+
|
|
| json_object_keys(parse_json(Utf8("{"a": 1, "b": {"c": 2}}"))) |
|
|
+---------------------------------------------------------------+
|
|
| [a, b] |
|
|
+---------------------------------------------------------------+
|
|
|
|
SELECT json_object_keys(parse_json('{}'));
|
|
|
|
+------------------------------------------+
|
|
| json_object_keys(parse_json(Utf8("{}"))) |
|
|
+------------------------------------------+
|
|
| [] |
|
|
+------------------------------------------+
|
|
|
|
SELECT json_object_keys(parse_json('[1, 2]'));
|
|
|
|
+----------------------------------------------+
|
|
| json_object_keys(parse_json(Utf8("[1, 2]"))) |
|
|
+----------------------------------------------+
|
|
| |
|
|
+----------------------------------------------+
|
|
|
|
SELECT json_object_keys(parse_json('null'));
|
|
|
|
+--------------------------------------------+
|
|
| json_object_keys(parse_json(Utf8("null"))) |
|
|
+--------------------------------------------+
|
|
| |
|
|
+--------------------------------------------+
|
|
|
|
SELECT json_object_keys(NULL);
|
|
|
|
+------------------------+
|
|
| json_object_keys(NULL) |
|
|
+------------------------+
|
|
| |
|
|
+------------------------+
|
|
|
|
--- json_path_exists ---
|
|
SELECT json_path_exists(parse_json('{"a": 1, "b": 2}'), '$.a');
|
|
|
|
+--------------------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("{"a": 1, "b": 2}")),Utf8("$.a")) |
|
|
+--------------------------------------------------------------------+
|
|
| true |
|
|
+--------------------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('{"a": 1, "b": 2}'), '$.c');
|
|
|
|
+--------------------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("{"a": 1, "b": 2}")),Utf8("$.c")) |
|
|
+--------------------------------------------------------------------+
|
|
| false |
|
|
+--------------------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('[1, 2]'), '[0]');
|
|
|
|
+----------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("[1, 2]")),Utf8("[0]")) |
|
|
+----------------------------------------------------------+
|
|
| true |
|
|
+----------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('[1, 2]'), '[2]');
|
|
|
|
+----------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("[1, 2]")),Utf8("[2]")) |
|
|
+----------------------------------------------------------+
|
|
| false |
|
|
+----------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('[1, 2]'), 'null');
|
|
|
|
+-----------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("[1, 2]")),Utf8("null")) |
|
|
+-----------------------------------------------------------+
|
|
| false |
|
|
+-----------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('null'), '$.a');
|
|
|
|
+--------------------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("null")),Utf8("$.a")) |
|
|
+--------------------------------------------------------+
|
|
| false |
|
|
+--------------------------------------------------------+
|
|
|
|
SELECT json_path_exists(NULL, '$.a');
|
|
|
|
+------------------------------------+
|
|
| json_path_exists(NULL,Utf8("$.a")) |
|
|
+------------------------------------+
|
|
| |
|
|
+------------------------------------+
|
|
|
|
SELECT json_path_exists(parse_json('{}'), NULL);
|
|
|
|
+-----------------------------------------------+
|
|
| json_path_exists(parse_json(Utf8("{}")),NULL) |
|
|
+-----------------------------------------------+
|
|
| |
|
|
+-----------------------------------------------+
|
|
|
|
--- json_path_match ---
|
|
SELECT json_path_match(parse_json('{"a": 1, "b": 2}'), '$.a == 1');
|
|
|
|
+------------------------------------------------------------------------+
|
|
| json_path_match(parse_json(Utf8("{"a": 1, "b": 2}")),Utf8("$.a == 1")) |
|
|
+------------------------------------------------------------------------+
|
|
| true |
|
|
+------------------------------------------------------------------------+
|
|
|
|
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), '$.b[0] > 1');
|
|
|
|
+-----------------------------------------------------------------------------+
|
|
| json_path_match(parse_json(Utf8("{"a":1,"b":[1,2,3]}")),Utf8("$.b[0] > 1")) |
|
|
+-----------------------------------------------------------------------------+
|
|
| false |
|
|
+-----------------------------------------------------------------------------+
|
|
|
|
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), '$.b[1 to last] >= 2');
|
|
|
|
+--------------------------------------------------------------------------------------+
|
|
| json_path_match(parse_json(Utf8("{"a":1,"b":[1,2,3]}")),Utf8("$.b[1 to last] >= 2")) |
|
|
+--------------------------------------------------------------------------------------+
|
|
| true |
|
|
+--------------------------------------------------------------------------------------+
|
|
|
|
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), 'null');
|
|
|
|
+-----------------------------------------------------------------------+
|
|
| json_path_match(parse_json(Utf8("{"a":1,"b":[1,2,3]}")),Utf8("null")) |
|
|
+-----------------------------------------------------------------------+
|
|
| |
|
|
+-----------------------------------------------------------------------+
|
|
|
|
SELECT json_path_match(parse_json('null'), '$.a == 1');
|
|
|
|
+------------------------------------------------------------+
|
|
| json_path_match(parse_json(Utf8("null")),Utf8("$.a == 1")) |
|
|
+------------------------------------------------------------+
|
|
| |
|
|
+------------------------------------------------------------+
|
|
|