Changeset: 59c158b27ea5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/59c158b27ea5
Added Files:
sql/test/nested/Tests/jdocs-direct-list.test
sql/test/nested/Tests/jdocs-wrapped-list.test
Removed Files:
sql/test/nested/Tests/jdocs.test
Modified Files:
sql/test/nested/Tests/All
Branch: nested
Log Message:
Splits jdocs test into two tests (one for direct and one for wrapped list)
diffs (260 lines):
diff --git a/sql/test/nested/Tests/All b/sql/test/nested/Tests/All
--- a/sql/test/nested/Tests/All
+++ b/sql/test/nested/Tests/All
@@ -4,7 +4,8 @@ fileloader
webclicks
array
composite
-jdocs
+jdocs-wrapped-list
+jdocs-direct-list
combinations
array_of_comp_with_array
comp_with_array_of_comp
diff --git a/sql/test/nested/Tests/jdocs-direct-list.test
b/sql/test/nested/Tests/jdocs-direct-list.test
new file mode 100644
--- /dev/null
+++ b/sql/test/nested/Tests/jdocs-direct-list.test
@@ -0,0 +1,67 @@
+## in this test the list member of the json document is directly in the
+## composite type e.g. "actions":[...]
+
+statement ok
+create type elem_t as (key text, val int)
+
+statement ok
+create type list_obj_t as (elem elem_t)
+
+statement ok
+create type jdoc_t as (name text, id int, actions list_obj_t[])
+
+statement ok
+create table jdocs (jd jdoc_t)
+
+query T nosort
+select
cast('{"name":"test_one","id":42,"actions":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}'
as json)
+----
+{"name":"test_one","id":42,"actions":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}
+
+statement ok
+insert into jdocs select
cast('{"name":"test_one","id":42,"actions":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}'
as json)
+
+query T nosort
+select
cast('{"name":"test_two","id":43,"actions":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }' as json)
+----
+{"name":"test_two","id":43,"actions":[{"elem":{"key":"tic","val":20}},{"elem":{"key":"tac","val":21}}]}
+
+statement ok
+insert into jdocs select
cast('{"name":"test_two","id":43,"actions":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }' as json)
+
+query TIT nosort
+select jd.name, jd.id, ua.elem from jdocs, unnest(jd.actions) as ua
+----
+test_one
+42
+("ping", 10)
+test_one
+42
+("pong", 11)
+test_two
+43
+("tic", 20)
+test_two
+43
+("tac", 21)
+
+query TITI nosort
+select jd.name, jd.id, ua.elem.key, ua.elem.val from jdocs, unnest(jd.actions)
as ua
+----
+test_one
+42
+ping
+10
+test_one
+42
+pong
+11
+test_two
+43
+tic
+20
+test_two
+43
+tac
+21
+
diff --git a/sql/test/nested/Tests/jdocs-wrapped-list.test
b/sql/test/nested/Tests/jdocs-wrapped-list.test
new file mode 100644
--- /dev/null
+++ b/sql/test/nested/Tests/jdocs-wrapped-list.test
@@ -0,0 +1,70 @@
+## in this test we the list member of the json document is wrapped
+## around act_list composite type e.g. "actions":{"list":[...]}
+
+statement ok
+create type elem_t as (key text, val int)
+
+statement ok
+create type list_obj_t as (elem elem_t)
+
+statement ok
+create type act_list as (list list_obj_t[])
+
+statement ok
+create type jdoc_t as (name text, id int, actions act_list)
+
+statement ok
+create table jdocs (jd jdoc_t)
+
+query T nosort
+select
cast('{"name":"test_one","id":42,"actions":{"list":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}}'
as json)
+----
+{"name":"test_one","id":42,"actions":{"list":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}}
+
+statement ok
+insert into jdocs select
cast('{"name":"test_one","id":42,"actions":{"list":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}}'
as json)
+
+query T nosort
+select
cast('{"name":"test_two","id":43,"actions":{"list":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }}' as json)
+----
+{"name":"test_two","id":43,"actions":{"list":[{"elem":{"key":"tic","val":20}},{"elem":{"key":"tac","val":21}}]}}
+
+statement ok
+insert into jdocs select
cast('{"name":"test_two","id":43,"actions":{"list":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }}' as json)
+
+query TIT nosort
+select jd.name, jd.id, ua.elem from jdocs, unnest(jd.actions.list) as ua
+----
+test_one
+42
+("ping", 10)
+test_one
+42
+("pong", 11)
+test_two
+43
+("tic", 20)
+test_two
+43
+("tac", 21)
+
+query TITI nosort
+select jd.name, jd.id, ua.elem.key, ua.elem.val from jdocs,
unnest(jd.actions.list) as ua
+----
+test_one
+42
+ping
+10
+test_one
+42
+pong
+11
+test_two
+43
+tic
+20
+test_two
+43
+tac
+21
+
diff --git a/sql/test/nested/Tests/jdocs.test b/sql/test/nested/Tests/jdocs.test
deleted file mode 100644
--- a/sql/test/nested/Tests/jdocs.test
+++ /dev/null
@@ -1,95 +0,0 @@
-statement ok
-create type elem_t as (key text, val int)
-
-statement ok
-create type list_entry_t as (elem elem_t)
-
--- the list member is directly in the composite type
-statement ok
-create type jd_freelist_t as (name text, id int, actions list_entry_t[])
-
-statement ok
-create type act_list as (list list_entry_t[])
-
--- the list member is wrapped around act_list composite type
-statement ok
-create type jd_wraplist_t as (name text, id int, actions act_list)
-
--- json docs with free list e.g. "actions":[...]
-
-statement ok
-create table fljdocs (jd jd_freelist_t)
-
-statement ok
-insert into fljdocs select
cast('{"name":"test_one","id":42,"actions":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}'
as json)
-
-statement ok
-insert into fljdocs select
cast('{"name":"test_two","id":43,"actions":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }' as json)
-
-query TIT nosort
-select jd.name, jd.id, act.elem from fljdocs, unnest(jd.actions) act
-----
-test_one
-42
-("ping", 10)
-test_one
-42
-("pong", 11)
-test_two
-43
-("tic", 20)
-test_two
-43
-("tac", 21)
-
-query TITI nosort
-select jd.name, jd.id, act.elem.key, act.elem.val from fljdocs,
unnest(jd.actions) act
-----
-test_one
-42
-ping
-10
-test_one
-42
-pong
-11
-test_two
-43
-tic
-20
-test_two
-43
-tac
-21
-
--- json docs with wrapped list e.g. "actions":{"list":[...]}
-
-statement ok
-create table wljdocs (jd jd_wraplist_t)
-
-statement ok
-insert into wljdocs select
cast('{"name":"test_one","id":42,"actions":{"list":[{"elem":{"key":"ping","val":10}},{"elem":{"key":"pong","val":11}}]}}'
as json)
-
-statement ok
-insert into wljdocs select
cast('{"name":"test_two","id":43,"actions":{"list":[{"elem":{"key":"tic","val":20}},
{"elem":{"key":"tac","val":21}}] }}' as json)
-
-query TITI nosort
-select jd.name, jd.id, act.elem.key, act.elem.val from fljdocs,
unnest(jd.actions) act
-----
-test_one
-42
-ping
-10
-test_one
-42
-pong
-11
-test_two
-43
-tic
-20
-test_two
-43
-tac
-21
-
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]