diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql')
-rw-r--r-- | yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql b/yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql new file mode 100644 index 0000000000..c21b6d766e --- /dev/null +++ b/yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql @@ -0,0 +1,93 @@ +select jsonb '{"a": 12}' @? '$'; +select jsonb '{"a": 12}' @? '1'; +select jsonb '{"a": 12}' @? '$.a.b'; +select jsonb '{"a": 12}' @? '$.b'; +select jsonb '{"a": 12}' @? '$.a + 2'; +select jsonb '{"a": 12}' @? '$.b + 2'; +select jsonb '{"a": {"a": 12}}' @? '$.a.a'; +select jsonb '{"a": {"a": 12}}' @? '$.*.a'; +select jsonb '{"b": {"a": 12}}' @? '$.*.a'; +select jsonb '{"b": {"a": 12}}' @? '$.*.b'; +select jsonb '{"b": {"a": 12}}' @? 'strict $.*.b'; +select jsonb '{}' @? '$.*'; +select jsonb '{"a": 1}' @? '$.*'; +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{1}'; +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{2}'; +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{3}'; +select jsonb '[]' @? '$[*]'; +select jsonb '[1]' @? '$[*]'; +select jsonb '[1]' @? '$[1]'; +select jsonb '[1]' @? 'strict $[1]'; +select jsonb '[1]' @? 'lax $[10000000000000000]'; +select jsonb '[1]' @? 'strict $[10000000000000000]'; +select jsonb '[1]' @? '$[0]'; +select jsonb '[1]' @? '$[0.3]'; +select jsonb '[1]' @? '$[0.5]'; +select jsonb '[1]' @? '$[0.9]'; +select jsonb '[1]' @? '$[1.2]'; +select jsonb '[1]' @? 'strict $[1.2]'; +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] > @.b[*])'; +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] >= @.b[*])'; +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? '$ ? (@.a[*] >= @.b[*])'; +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? 'strict $ ? (@.a[*] >= @.b[*])'; +select jsonb '{"a": [1,2,3], "b": [3,4,null]}' @? '$ ? (@.a[*] >= @.b[*])'; +select jsonb '1' @? '$ ? ((@ == "1") is unknown)'; +select jsonb '1' @? '$ ? ((@ == 1) is unknown)'; +select jsonb '[{"a": 1}, {"a": 2}]' @? '$[0 to 1] ? (@.a > 1)'; +select jsonb '{"a": {"b": 1}}' @? '$.**.b ? ( @ > 0)'; +select jsonb '{"a": {"b": 1}}' @? '$.**{0}.b ? ( @ > 0)'; +select jsonb '{"a": {"b": 1}}' @? '$.**{1}.b ? ( @ > 0)'; +select jsonb '{"a": {"b": 1}}' @? '$.**{0 to last}.b ? ( @ > 0)'; +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to last}.b ? ( @ > 0)'; +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to 2}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0 to last}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to last}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to 2}.b ? ( @ > 0)'; +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{2 to 3}.b ? ( @ > 0)'; +select jsonb '{"a": 1, "b":1}' @? '$ ? (@.a == @.b)'; +select jsonb '{"c": {"a": 1, "b":1}}' @? '$ ? (@.a == @.b)'; +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? (@.a == @.b)'; +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? ($.c.a == @.b)'; +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.* ? (@.a == @.b)'; +select jsonb '{"a": 1, "b":1}' @? '$.** ? (@.a == @.b)'; +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.** ? (@.a == @.b)'; +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - 1)'; +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -1)'; +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -@.b)'; +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - @.b)'; +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - @.b)'; +select jsonb '{"c": {"a": 2, "b":1}}' @? '$.** ? (@.a == 1 - - @.b)'; +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - +@.b)'; +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +2)'; +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +3)'; +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -2)'; +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -3)'; +select jsonb '1' @? '$ ? ($ > 0)'; +select jsonb '["1",2,0,3]' @? '-$[*]'; +select jsonb '[1,"2",0,3]' @? '-$[*]'; +select jsonb '["1",2,0,3]' @? 'strict -$[*]'; +select jsonb '[1,"2",0,3]' @? 'strict -$[*]'; +select jsonb '2' @? '$ == "2"'; +select jsonb '2' @@ '$ > 1'; +select jsonb '2' @@ '$ <= 1'; +select jsonb '2' @@ '$ == "2"'; +select jsonb '2' @@ '1'; +select jsonb '{}' @@ '$'; +select jsonb '[]' @@ '$'; +select jsonb '[1,2,3]' @@ '$[*]'; +select jsonb '[]' @@ '$[*]'; +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue()'; +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue().key'; +select jsonb '"10-03-2017"' @? '$.datetime("dd-mm-yyyy")'; +set time zone '+00'; +set time zone '+10'; +set time zone default; +set time zone '+00'; +set time zone default; +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*].a ? (@ > 1)'; +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*] ? (@.a > 2)'; +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 1'; +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 2'; |