Changeset: 6ec7abafbb57 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6ec7abafbb57
Added Files:
sql/test/nested/Tests/jdocs.test
Modified Files:
sql/test/nested/Tests/All
Branch: nested
Log Message:
Adds new test with small json example
diffs (92 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
@@ -5,3 +5,4 @@ webclicks
array
composite
inserts
+jdocs
diff --git a/sql/test/nested/Tests/jdocs.test b/sql/test/nested/Tests/jdocs.test
new file mode 100644
--- /dev/null
+++ b/sql/test/nested/Tests/jdocs.test
@@ -0,0 +1,79 @@
+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 TITI nosort jsondata
+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 jsondata
+#select jd.name, jd.id, act.list.elem.key, act.list.elem.val from fljdocs,
unnest(jd.actions.list) 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]