Changeset: b5ab3f62afe9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5ab3f62afe9
Added Files:
sql/test/json/Tests/load.stable.err
sql/test/json/Tests/load.stable.out
Modified Files:
monetdb5/modules/atoms/Tests/json07.stable.out
monetdb5/modules/atoms/Tests/json13.mal
monetdb5/modules/atoms/Tests/json13.stable.out
monetdb5/modules/atoms/json.c
Branch: default
Log Message:
Better test on decimal point, initialized returns
diffs (201 lines):
diff --git a/monetdb5/modules/atoms/Tests/json07.stable.out
b/monetdb5/modules/atoms/Tests/json07.stable.out
--- a/monetdb5/modules/atoms/Tests/json07.stable.out
+++ b/monetdb5/modules/atoms/Tests/json07.stable.out
@@ -38,7 +38,7 @@ function user.main():void;
v1 := json.values(js);
io.print(v1);
end main;
-[ "[myList,yours]" ]
+[ "[\"myList\",\"yours\"]" ]
[ "[23,[\"a\",\"b\"]]" ]
#--------------------------#
# h t # name
@@ -52,7 +52,7 @@ end main;
#--------------------------#
[ 0@0, "23" ]
[ 1@0, "[\"a\",\"b\"]" ]
-[ "[myBoolean,myList,myMap,myObject,myJsonObject]" ]
+[ "[\"myBoolean\",\"myList\",\"myMap\",\"myObject\",\"myJsonObject\"]" ]
[
"[true,[\"a\",\"b\"],{\"c\":\"d\",\"a\":\"b\"},\"myClass\",{\"myString\":\"myStringValue\"}]"
]
#--------------------------#
# h t # name
diff --git a/monetdb5/modules/atoms/Tests/json13.mal
b/monetdb5/modules/atoms/Tests/json13.mal
--- a/monetdb5/modules/atoms/Tests/json13.mal
+++ b/monetdb5/modules/atoms/Tests/json13.mal
@@ -3,8 +3,6 @@ js:= json.new("{ \"store\": { \"book\":
json.dump(js);
-p:= json.filter(js,"$");
-io.print(p);
p:= json.filter(js,".store.book[*]..author");
io.print(p);
p:= json.filter(js,".store.book..author");
@@ -25,6 +23,8 @@ p:= json.filter(js,"store.book.[1].autho
io.print(p);
p:= json.filter(js,"store.book[1]..author");
io.print(p);
+p:= json.filter(js,"$");
+io.print(p);
#p:= json.filter(js,"..book[-1:]");
#io.print(p);
#p:= json.filter(js,"..book[0,1]");
diff --git a/monetdb5/modules/atoms/Tests/json13.stable.out
b/monetdb5/modules/atoms/Tests/json13.stable.out
--- a/monetdb5/modules/atoms/Tests/json13.stable.out
+++ b/monetdb5/modules/atoms/Tests/json13.stable.out
@@ -22,8 +22,6 @@ function user.main():void;
# taken from http://goessner.net/articles/JsonPath/
js := json.new("{ \"store\": { \"book\": [ { \"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 } } }");
json.dump(js);
- p := json.filter(js,"$");
- io.print(p);
p := json.filter(js,".store.book[*]..author");
io.print(p);
p := json.filter(js,".store.book..author");
@@ -44,6 +42,8 @@ function user.main():void;
io.print(p);
p := json.filter(js,"store.book[1]..author");
io.print(p);
+ p := json.filter(js,"$");
+ io.print(p);
#p:= json.filter(js,"..book[-1:]");
#io.print(p);
#p:= json.filter(js,"..book[0,1]");
@@ -108,7 +108,6 @@ end main;
[52] string child 0 list "red"
[53] element child 54 list price
[54] number child 0 list 19.95
-[ "[{ \"store\": { \"book\": [ { \"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 } } }]" ]
[ "[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
]
[ "[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
]
[ "[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
]
@@ -119,6 +118,7 @@ end main;
[ "[{ \"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\":
\"Sword of Honour\", \"price\": 12.99 }]" ]
[ "[\"Evelyn Waugh\"]" ]
[ "[]" ]
+[ "[{ \"store\": { \"book\": [ { \"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 } } }]" ]
# 11:20:40 >
# 11:20:40 > "Done."
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -357,7 +357,7 @@ JSONcompile(char *expr, pattern terms[])
if( t )
throw(MAL,"json.compile","Root node must be
first");
terms[t].token = ROOT_STEP;
- if ( !(*(s+1) == '.' || *(s+1) =='[' || *s == 0) )
+ if ( !(*(s+1) == '.' || *(s+1) =='[' || *(s+1) == 0) )
throw(MAL,"json.compile","Root node must be
first");
}
if (*s == '.' && *(s + 1) == '.') {
@@ -614,12 +614,6 @@ JSONnumberParser(char *j, char **next, i
throw(MAL, "json.parser", "Number expected");
return MAL_SUCCEED;
}
- if (*j == '0' && *(j + 1) != '.'){
- *next =j;
- if(! silent)
- throw(MAL, "json.parser", "Decimal expected");
- return MAL_SUCCEED;
- }
for (; *j; j++)
if (*j < '0' || *j > '9')
break;
diff --git a/sql/test/json/Tests/load.stable.err
b/sql/test/json/Tests/load.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/json/Tests/load.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'load` in directory 'sql/test/json` itself:
+
+
+# 10:09:27 >
+# 10:09:27 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36064" "--set"
"mapi_usock=/var/tmp/mtest-19875/.s.monetdb.36064" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_sql_test_json"
"--set" "mal_listing=0"
+# 10:09:27 >
+
+# builtin opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 36064
+# cmdline opt mapi_usock = /var/tmp/mtest-19875/.s.monetdb.36064
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/export/scratch1/mk/current//Linux/var/MonetDB/mTests_sql_test_json
+# cmdline opt mal_listing = 0
+
+# 10:09:27 >
+# 10:09:27 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-19875" "--port=36064"
+# 10:09:27 >
+
+
+# 10:09:27 >
+# 10:09:27 > "Done."
+# 10:09:27 >
+
diff --git a/sql/test/json/Tests/load.stable.out
b/sql/test/json/Tests/load.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/json/Tests/load.stable.out
@@ -0,0 +1,52 @@
+stdout of test 'load` in directory 'sql/test/json` itself:
+
+
+# 10:09:27 >
+# 10:09:27 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=36064" "--set"
"mapi_usock=/var/tmp/mtest-19875/.s.monetdb.36064" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_sql_test_json"
"--set" "mal_listing=0"
+# 10:09:27 >
+
+# MonetDB 5 server v11.18.0
+# This is an unreleased version
+# Serving database 'mTests_sql_test_json', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 15.591 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.ins.cwi.nl:36064/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-19875/.s.monetdb.36064
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 10:09:27 >
+# 10:09:27 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-19875" "--port=36064"
+# 10:09:27 >
+
+#create table jstmp(j json);
+#copy 10 records into jstmp from stdin;
+#{"nested_obj": {"num": 4, "str": "GBRDCMBQ"}, "dyn2": true, "dyn1": 9,
"nested_arr": ["especially"], "str2": "GBRDCMBQ", "str1": "GBRDCMBQGE======",
"sparse_093": "GBRDCMBQGE======", "thousandth": 9, "sparse_090":
"GBRDCMBQGE======", "sparse_091": "GBRDCMBQGE======", "sparse_092":
"GBRDCMBQGE======", "num": 9, "bool": true, "sparse_095": "GBRDCMBQGE======",
"sparse_096": "GBRDCMBQGE======", "sparse_097": "GBRDCMBQGE======",
"sparse_098": "GBRDCMBQGE======", "sparse_094": "GBRDCMBQGE======",
"sparse_099": "GBRDCMBQGE======"}
+[ 10 ]
+#select json.filter(j,'..num') from jstmp;
+% sys.L # table_name
+% filter_j # name
+% json # type
+% 5 # length
+[ "[4,9]" ]
+[ "[2,7]" ]
+[ "[3,8]" ]
+[ "[0,5]" ]
+[ "[8,3]" ]
+[ "[9,4]" ]
+[ "[6,1]" ]
+[ "[7,2]" ]
+[ "[5,0]" ]
+[ "[1,6]" ]
+#drop table jstmp;
+
+# 10:09:27 >
+# 10:09:27 > "Done."
+# 10:09:27 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list