Changeset: 897055d69e23 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=897055d69e23 Added Files: sql/test/json/sqllogictest/Tests/All sql/test/json/sqllogictest/Tests/SingleServer sql/test/json/sqllogictest/Tests/aggregate00.test sql/test/json/sqllogictest/Tests/aggregate01.test sql/test/json/sqllogictest/Tests/books.test sql/test/json/sqllogictest/Tests/bulkjson.test sql/test/json/sqllogictest/Tests/bulklength.test sql/test/json/sqllogictest/Tests/bulkvalid.test sql/test/json/sqllogictest/Tests/coercions.test sql/test/json/sqllogictest/Tests/components.test sql/test/json/sqllogictest/Tests/jsonkeyarray.Bug-6858.test sql/test/json/sqllogictest/Tests/jsonnumber.Bug-6932.test sql/test/json/sqllogictest/Tests/jsonparser.Bug-6943.test sql/test/json/sqllogictest/Tests/jsontext.Bug-6859.test sql/test/json/sqllogictest/Tests/jsonvalidity.Bug-3753.test sql/test/json/sqllogictest/Tests/load.test sql/test/json/sqllogictest/Tests/miniexample.test sql/test/json/sqllogictest/Tests/parsing.test sql/test/json/sqllogictest/Tests/pathexpr.test sql/test/json/sqllogictest/Tests/pgexample.test sql/test/json/sqllogictest/Tests/shop.test sql/test/json/sqllogictest/Tests/spaceissue.test Branch: mtest Log Message:
convert json test to sqllogic diffs (truncated from 1469 to 300 lines): diff --git a/sql/test/json/sqllogictest/Tests/All b/sql/test/json/sqllogictest/Tests/All new file mode 100644 --- /dev/null +++ b/sql/test/json/sqllogictest/Tests/All @@ -0,0 +1,20 @@ +spaceissue +parsing +books +pgexample +bulkjson +bulklength +bulkvalid +coercions +pathexpr +components +load +aggregate00 +aggregate01 +shop +jsonvalidity.Bug-3753 +HAVE_DATA_PATH?load_twitter_data +jsonkeyarray.Bug-6858 +jsontext.Bug-6859 +jsonnumber.Bug-6932 +jsonparser.Bug-6943 diff --git a/sql/test/json/sqllogictest/Tests/SingleServer b/sql/test/json/sqllogictest/Tests/SingleServer new file mode 100644 diff --git a/sql/test/json/sqllogictest/Tests/aggregate00.test b/sql/test/json/sqllogictest/Tests/aggregate00.test new file mode 100644 --- /dev/null +++ b/sql/test/json/sqllogictest/Tests/aggregate00.test @@ -0,0 +1,79 @@ +statement ok +create table aggrtest00 ( col1 varchar(10), col2 integer ) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +NULL + +statement ok +insert into aggrtest00 values ('hallo', 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +[ "hallo" ] + +statement ok +insert into aggrtest00 values ('world', 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +[ "hallo", "world" ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 group by col2 +---- +[ "hallo", "world" ] + +statement ok +insert into aggrtest00 values ('foobar', 2) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +[ "hallo", "world", "foobar" ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 group by col2 +---- +[ "foobar" ] +[ "hallo", "world" ] + +statement ok +delete from aggrtest00 + +statement ok +insert into aggrtest00 values (NULL, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +NULL + +statement ok +insert into aggrtest00 values ('hello', 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +[ "hello" ] + +statement ok +insert into aggrtest00 values ('world', 2) + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 +---- +[ "hello", "world" ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest00 group by col2 +---- +[ "hello" ] +[ "world" ] + +statement ok +drop table aggrtest00 + diff --git a/sql/test/json/sqllogictest/Tests/aggregate01.test b/sql/test/json/sqllogictest/Tests/aggregate01.test new file mode 100644 --- /dev/null +++ b/sql/test/json/sqllogictest/Tests/aggregate01.test @@ -0,0 +1,118 @@ +statement ok +create table aggrtest01 ( col1 double, col2 integer ) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +NULL + +statement ok +insert into aggrtest01 values (0.1234, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400 ] + +statement ok +insert into aggrtest01 values (5.6789, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400, 5.678900 ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 group by col2 +---- +[ 0.123400, 5.678900 ] + +statement ok +insert into aggrtest01 values (0.516273849, 2) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400, 5.678900, 0.516274 ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 group by col2 +---- +[ 0.123400, 5.678900 ] +[ 0.516274 ] + +statement ok +delete from aggrtest01 + +statement ok +insert into aggrtest01 values (NULL, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +NULL + +statement ok +insert into aggrtest01 values (NULL, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +NULL + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 group by col2 +---- +[ ] + +statement ok +insert into aggrtest01 values (0.1234, 1) + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400 ] + +statement ok +insert into aggrtest01 values (0.516273849, 2) + +query RI rowsort +select * from aggrtest01 +---- +0.123 +1 +0.516 +2 +NULL +1 +NULL +1 + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400, 0.516274 ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 group by col2 +---- +[ 0.123400 ] +[ 0.516274 ] + +statement ok +delete from aggrtest01 where col1 is null + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 +---- +[ 0.123400, 0.516274 ] + +query T rowsort +select json.tojsonarray(col1) from aggrtest01 group by col2 +---- +[ 0.123400 ] +[ 0.516274 ] + +statement ok +drop table aggrtest01 + diff --git a/sql/test/json/sqllogictest/Tests/books.test b/sql/test/json/sqllogictest/Tests/books.test new file mode 100644 --- /dev/null +++ b/sql/test/json/sqllogictest/Tests/books.test @@ -0,0 +1,82 @@ +statement ok +create table books(i integer, j json) + +statement ok +insert into books values( 1, ' { "store": { + "books": [ + { "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95 + }, + { "category": "fiction", + "author": "Evelyn Waugh", + "title": "Sword of Honour", + "price": 12.99 + }, + { "category": "fiction", + "author": "Herman Melville", + "title": "Moby Dick", + "isbn": "0-553-21311-3", + "price": 8.99 + }, + { "category": "fiction", + "author": "J. R. R. Tolkien", + "title": "The Lord of the Rings", + "isbn": "0-395-19395-8", + "price": 22.99 + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + } +}') + +query IT rowsort +select * from books +---- +1 + { "store": {@ "books": [@ { "category": "reference",@ "author": "Nigel Rees",@ "title": "Sayings of the Century",@ "price": 8.95@ },@ { "category": "fiction",@ "author": "Evelyn Waugh",@ "title": "Sword of Honour",@ "price": 12.99@ },@ { "category": "fiction",@ "author": "Herman Melville",@ "title": "Moby Dick",@ "isbn": "0-553-21311-3",@ "price": 8.99@ },@ { "category": "fiction",@ "author": "J. R. R. Tolkien",@ "title": "The Lord of the Rings",@ "isbn": "0-395-19395-8",@ "price": 22.99@ }@ ],@ "bicycle": {@ "color": "red",@ "price": 19.95@ }@ }@} + +query T rowsort +SELECT json.filter(j,'store.books.[1]..author') FROM books +---- +["Evelyn Waugh"] + +query T rowsort +SELECT json.filter(j,'..books..author[1]') AS j FROM ( + SELECT json.filter(j,'store') AS j FROM books +) AS L1 +---- +["Evelyn Waugh"] + +query T rowsort +SELECT json.filter(j,'..author') FROM books +---- +["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"] + +query T rowsort +SELECT json.filter(j,'store.books[*]..author') FROM books _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list