Changeset: 15a3502f85ba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=15a3502f85ba
Modified Files:
        monetdb5/extras/pyapi/pyapi.c
        sql/backends/monet5/Tests/pyapi04.stable.err
        sql/backends/monet5/Tests/pyapi04.stable.out
Branch: pyapi
Log Message:

When no BAT return type is specified, take the type of the returned Python 
object instead of throwing an error.


diffs (54 lines):

diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c
--- a/monetdb5/extras/pyapi/pyapi.c
+++ b/monetdb5/extras/pyapi/pyapi.c
@@ -988,9 +988,8 @@ returnvalues:
             bat_type = getColumnType(getArgType(mb,pci,i));
 
             if (bat_type == TYPE_any || bat_type == TYPE_void) {
+                bat_type = PyType_ToBat(ret->result_type);
                 getArgType(mb,pci,i) = bat_type;
-                msg = createException(MAL, "pyapi.eval", "Unknown return 
value, possibly projecting with no parameters.");
-                goto wrapup;
             }
         } else {
             bat_type = PyType_ToBat(ret->result_type);
diff --git a/sql/backends/monet5/Tests/pyapi04.stable.err 
b/sql/backends/monet5/Tests/pyapi04.stable.err
--- a/sql/backends/monet5/Tests/pyapi04.stable.err
+++ b/sql/backends/monet5/Tests/pyapi04.stable.err
@@ -31,15 +31,6 @@ stderr of test 'pyapi04` in directory 's
 # 15:05:16 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-16558" "--port=34890"
 # 15:05:16 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-16558/.s.monetdb.34890
-QUERY = SELECT pyapi04() FROM dval;
-ERROR = !Unknown return value, possibly projecting with no parameters.
-MAPI  = (monetdb) /var/tmp/mtest-16558/.s.monetdb.34890
-QUERY = DROP FUNCTION pyapi04;
-ERROR = !current transaction is aborted (please ROLLBACK)
-MAPI  = (monetdb) /var/tmp/mtest-16558/.s.monetdb.34890
-QUERY = DROP TABLE dval;
-ERROR = !current transaction is aborted (please ROLLBACK)
 
 # 15:05:16 >  
 # 15:05:16 >  "Done."
diff --git a/sql/backends/monet5/Tests/pyapi04.stable.out 
b/sql/backends/monet5/Tests/pyapi04.stable.out
--- a/sql/backends/monet5/Tests/pyapi04.stable.out
+++ b/sql/backends/monet5/Tests/pyapi04.stable.out
@@ -75,6 +75,17 @@ Ready.
 #{
 #    return [True] * 4
 #};
+#SELECT pyapi04() FROM dval;
+% .L # table_name
+% pyapi04 # name
+% boolean # type
+% 5 # length
+[ true ]
+[ true ]
+[ true ]
+[ true ]
+#DROP FUNCTION pyapi04;
+#DROP TABLE dval;
 #ROLLBACK;
 
 # 15:05:16 >  
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to