Changeset: fe4675aacf2f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fe4675aacf2f
Added Files:
        sql/backends/monet5/Tests/pyapi21.sql
        sql/backends/monet5/Tests/pyapi21.stable.err
        sql/backends/monet5/Tests/pyapi21.stable.out
        sql/backends/monet5/Tests/pyapi22.sql
        sql/backends/monet5/Tests/pyapi22.stable.err
        sql/backends/monet5/Tests/pyapi22.stable.out
Modified Files:
        sql/backends/monet5/Tests/All
        sql/backends/monet5/Tests/inlineUDF.sql
Branch: pyapi
Log Message:

New testcases.


diffs (truncated from 452 to 300 lines):

diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All
--- a/sql/backends/monet5/Tests/All
+++ b/sql/backends/monet5/Tests/All
@@ -18,6 +18,9 @@ HAVE_LIBPY?pyapi16
 HAVE_LIBPY?pyapi17
 HAVE_LIBPY?pyapi18
 HAVE_LIBPY?pyapi19
+HAVE_LIBPY?pyapi20
+HAVE_LIBPY?pyapi21
+HAVE_LIBPY?pyapi22
 
 #HAVE_LIBR?rapi00
 #HAVE_LIBR?rapi01
@@ -31,9 +34,9 @@ HAVE_LIBPY?pyapi19
 #HAVE_LIBR?rapi09
 #HAVE_LIBR?rapi10
 #HAVE_LIBR?rapi12
-HAVE_LIBR?rapi13
-HAVE_LIBR?rapi14
-HAVE_LIBR?rapi15
+#HAVE_LIBR?rapi13
+#HAVE_LIBR?rapi14
+#HAVE_LIBR?rapi15
 
 # should this work?
 #inlineUDF
diff --git a/sql/backends/monet5/Tests/inlineUDF.sql 
b/sql/backends/monet5/Tests/inlineUDF.sql
--- a/sql/backends/monet5/Tests/inlineUDF.sql
+++ b/sql/backends/monet5/Tests/inlineUDF.sql
@@ -3,9 +3,9 @@
 -- The arguments are named after the signature
 -- The return variable is called 'ret'
 
-create function one() returns integer language C { *ret = 1; return NULL; }
-create function addtwo(i integer, j integer) returns integer language C { *ret 
= *i + *j; return NULL;}
-create function adderror(i integer, j integer) returns integer language C { if 
( *i == int_nil || *j == int_nil) throw(SQL,"udf","Nil not allowed"); *ret = *i 
+ *j; return NULL;}
+create function one() returns integer language C { *ret = 1; return NULL; };
+create function addtwo(i integer, j integer) returns integer language C { *ret 
= *i + *j; return NULL;};
+create function adderror(i integer, j integer) returns integer language C { if 
( *i == int_nil || *j == int_nil) throw(SQL,"udf","Nil not allowed"); *ret = *i 
+ *j; return NULL;};
 
 select one();
 select addtwo(one(),one());
diff --git a/sql/backends/monet5/Tests/pyapi21.sql 
b/sql/backends/monet5/Tests/pyapi21.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi21.sql
@@ -0,0 +1,37 @@
+
+START TRANSACTION;
+
+
+CREATE FUNCTION pyapi21_create() returns TABLE(s STRING)
+language P
+{
+       import cPickle
+    a = 3
+    b = "hello"
+    c = [3, 37, "hello"]
+    d = numpy.array([44, 55])
+    e = numpy.ma.masked_array([1, 2, 3], [0, 1, 0])
+
+
+    result = dict()
+    result['s'] = [cPickle.dumps(x) for x in [a,b,c,d,e]]
+    return result
+};
+
+CREATE FUNCTION pyapi21_load(objects STRING) returns BOOLEAN
+LANGUAGE P
+{
+       import cPickle
+       for x in [cPickle.loads(y) for y in objects]:
+               print str(type(x)) + ": " + str(x)
+       return True
+};
+
+CREATE TABLE python_objects AS SELECT * FROM pyapi21_create() WITH DATA;
+SELECT pyapi21_load(s) FROM python_objects;
+
+
+DROP FUNCTION pyapi21_create; DROP FUNCTION pyapi21_load; DROP TABLE 
python_objects;
+
+ROLLBACK;
+
diff --git a/sql/backends/monet5/Tests/pyapi21.stable.err 
b/sql/backends/monet5/Tests/pyapi21.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi21.stable.err
@@ -0,0 +1,38 @@
+stderr of test 'pyapi21` in directory 'sql/backends/monet5` itself:
+
+
+# 10:23:58 >  
+# 10:23:58 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35549" "--set" 
"mapi_usock=/var/tmp/mtest-6278/.s.monetdb.35549" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/mytherin/opt/var/MonetDB/mTests_sql_backends_monet5" "--set" 
"mal_listing=0" "--set" "embedded_r=true" "--set" "embedded_py=true"
+# 10:23:58 >  
+
+# builtin opt  gdk_dbpath = /home/mytherin/opt/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 = 35549
+# cmdline opt  mapi_usock = /var/tmp/mtest-6278/.s.monetdb.35549
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/home/mytherin/opt/var/MonetDB/mTests_sql_backends_monet5
+# cmdline opt  mal_listing = 0
+# cmdline opt  embedded_r = true
+# cmdline opt  embedded_py = true
+# cmdline opt  gdk_debug = 536870922
+
+# 10:23:58 >  
+# 10:23:58 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-6278" "--port=35549"
+# 10:23:58 >  
+
+
+# 10:23:59 >  
+# 10:23:59 >  "Done."
+# 10:23:59 >  
+
diff --git a/sql/backends/monet5/Tests/pyapi21.stable.out 
b/sql/backends/monet5/Tests/pyapi21.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi21.stable.out
@@ -0,0 +1,74 @@
+stdout of test 'pyapi21` in directory 'sql/backends/monet5` itself:
+
+
+# 10:23:58 >  
+# 10:23:58 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35549" "--set" 
"mapi_usock=/var/tmp/mtest-6278/.s.monetdb.35549" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/mytherin/opt/var/MonetDB/mTests_sql_backends_monet5" "--set" 
"mal_listing=0" "--set" "embedded_r=true" "--set" "embedded_py=true"
+# 10:23:58 >  
+
+# MonetDB 5 server v11.22.0
+# This is an unreleased version
+# Serving database 'mTests_sql_backends_monet5', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 7.684 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://mytherin-N750JV:35549/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-6278/.s.monetdb.35549
+# Start processing logs sql/sql_logs version 52200
+# Finished processing logs sql/sql_logs
+# MonetDB/SQL module loaded
+# MonetDB/Python module loaded
+# MonetDB/R   module loaded
+
+Ready.
+<type 'int'>: 3
+<type 'str'>: hello
+<type 'list'>: [3, 37, 'hello']
+<type 'numpy.ndarray'>: [44 55]
+<class 'numpy.ma.core.MaskedArray'>: [1 -- 3]
+
+# 10:23:58 >  
+# 10:23:58 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-6278" "--port=35549"
+# 10:23:58 >  
+
+#START TRANSACTION;
+#CREATE FUNCTION pyapi21_create() returns TABLE(s STRING)
+#language P
+#{
+#      import cPickle
+#    a = 3
+#    b = "hello"
+#    c = [3, 37, "hello"]
+#    d = numpy.array([44, 55])
+#    e = numpy.ma.masked_array([1, 2, 3], [0, 1, 0])
+#
+#
+#    result = dict()
+#    result['s'] = [cPickle.dumps(x) for x in [a,b,c,d,e]]
+#    return result
+#};
+#CREATE FUNCTION pyapi21_load(objects STRING) returns BOOLEAN
+#LANGUAGE P
+#{
+#      import cPickle
+#      for x in [cPickle.loads(y) for y in objects]:
+#              print str(type(x)) + ": " + str(x)
+#      return True
+#};
+#CREATE TABLE python_objects AS SELECT * FROM pyapi21_create() WITH DATA;
+#SELECT pyapi21_load(s) FROM python_objects;
+% sys.L # table_name
+% pyapi21_load_s # name
+% boolean # type
+% 5 # length
+[ true ]
+#DROP FUNCTION pyapi21_create; DROP FUNCTION pyapi21_load; DROP TABLE 
python_objects;
+#DROP FUNCTION pyapi21_create; DROP FUNCTION pyapi21_load; DROP TABLE 
python_objects;
+#DROP FUNCTION pyapi21_create; DROP FUNCTION pyapi21_load; DROP TABLE 
python_objects;
+#ROLLBACK;
+
+# 10:23:59 >  
+# 10:23:59 >  "Done."
+# 10:23:59 >  
+
diff --git a/sql/backends/monet5/Tests/pyapi22.sql 
b/sql/backends/monet5/Tests/pyapi22.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi22.sql
@@ -0,0 +1,58 @@
+
+START TRANSACTION;
+
+CREATE FUNCTION initialize_values() RETURNS TABLE(a BOOLEAN) LANGUAGE PYTHON
+{
+    _values['a'] = 3
+    _values['b'] = "hello"
+    _values[33] = [3, 37, "hello"]
+    _values['c'] = numpy.array([44, 55])
+    _values[22.77] = numpy.ma.masked_array([1, 2, 3], [0, 1, 0])
+    return True
+};
+
+CREATE FUNCTION clear_values() RETURNS TABLE(a BOOLEAN) LANGUAGE PYTHON
+{
+    for key in _values.keys():
+        del _values[key]
+    return True
+};
+
+CREATE FUNCTION store_values() RETURNS TABLE(keys STRING, vals STRING) 
LANGUAGE PYTHON
+{
+    import cPickle
+    result = dict()
+    result['keys'] = [cPickle.dumps(x) for x in _values.keys()]
+    result['vals'] = [cPickle.dumps(x) for x in _values.values()]
+    return result
+};
+
+CREATE FUNCTION restore_values(keys STRING, vals STRING) RETURNS BOOLEAN 
LANGUAGE PYTHON
+{
+    import cPickle
+    for key, value in zip([cPickle.loads(x) for x in keys], [cPickle.loads(x) 
for x in vals]):
+        _values[key] = value
+    return True
+};
+
+CREATE FUNCTION print_values() RETURNS TABLE(a BOOLEAN) LANGUAGE PYTHON
+{
+    print("Printing _values dictionary")
+    print("Items: %d" % len(_values))
+    for key,val in _values.iteritems():
+        print str(key) + ',' + str(val)
+    print("End\n")
+    return True
+};
+
+SELECT * FROM initialize_values();
+SELECT * FROM print_values();
+CREATE TABLE values_storage AS SELECT * FROM store_values() WITH DATA;
+SELECT * FROM clear_values();
+SELECT * FROM print_values();
+SELECT restore_values(keys, vals) FROM values_storage;
+SELECT * FROM print_values();
+
+DROP TABLE values_storage;
+
+ROLLBACK;
diff --git a/sql/backends/monet5/Tests/pyapi22.stable.err 
b/sql/backends/monet5/Tests/pyapi22.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi22.stable.err
@@ -0,0 +1,38 @@
+stderr of test 'pyapi22` in directory 'sql/backends/monet5` itself:
+
+
+# 13:00:01 >  
+# 13:00:01 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35894" "--set" 
"mapi_usock=/var/tmp/mtest-10726/.s.monetdb.35894" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/home/mytherin/opt/var/MonetDB/mTests_sql_backends_monet5" "--set" 
"mal_listing=0" "--set" "embedded_r=true" "--set" "embedded_py=true"
+# 13:00:01 >  
+
+# builtin opt  gdk_dbpath = /home/mytherin/opt/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 = 35894
+# cmdline opt  mapi_usock = /var/tmp/mtest-10726/.s.monetdb.35894
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/home/mytherin/opt/var/MonetDB/mTests_sql_backends_monet5
+# cmdline opt  mal_listing = 0
+# cmdline opt  embedded_r = true
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to