diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /yql/essentials/tests/postgresql/cases/jsonb_jsonpath.sql | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-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'; |