Changeset: 72c7bee4b094 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=72c7bee4b094
Added Files:
sql/backends/monet5/Tests/pyapi32.sql
sql/backends/monet5/Tests/pyapi32.stable.err
sql/backends/monet5/Tests/pyapi32.stable.out
Modified Files:
sql/backends/monet5/Tests/All
sql/backends/monet5/UDF/pyapi/pyapi.c
Branch: default
Log Message:
Fix assertion trigger on edge case where input BATs to UDF are empty.
This happens when there is a parallel function + filter, e.g.
SELECT parallel_function(i) FROM tbl WHERE attr > 50;
The partitioning happens before the filter function is executed, and thus
certain partitions can be empty if the filter function is "unbalanced" (e.g. if
you have values 1-100, and you filter on >50, the first few partitions will be
empty while the others will be filled entirely).
This used to throw an error because we did not expect empty input BATs; but now
we just return emptyBATs when this happens.
diffs (truncated from 527 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
@@ -50,6 +50,7 @@ HAVE_LIBPY?pyapi26
HAVE_LIBPY?pyapi27
HAVE_LIBPY?pyapi28
HAVE_LIBPY?pyapi29
+HAVE_LIBPY?pyapi32
# should this work?
#inlineUDF
diff --git a/sql/backends/monet5/Tests/pyapi32.sql
b/sql/backends/monet5/Tests/pyapi32.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi32.sql
@@ -0,0 +1,25 @@
+
+START TRANSACTION;
+
+
+CREATE FUNCTION pyapi32_gentbl() RETURNS TABLE(i TINYINT) LANGUAGE PYTHON {
+ return { 'i': numpy.arange(100) }
+};
+
+CREATE FUNCTION pyapi32_function(i INTEGER) RETURNS INTEGER LANGUAGE PYTHON {
+ return i * 2;
+};
+
+CREATE FUNCTION pyapi32_function_mapped(i INTEGER) RETURNS INTEGER LANGUAGE
PYTHON_MAP {
+ return i * 2;
+};
+
+CREATE TABLE integers AS SELECT * FROM pyapi32_gentbl() WITH DATA;
+
+SELECT pyapi32_function(i) FROM integers;
+SELECT pyapi32_function(i) FROM integers WHERE i > 50;
+
+SELECT pyapi32_function_mapped(i) FROM integers;
+SELECT pyapi32_function_mapped(i) FROM integers WHERE i > 50;
+
+ROLLBACK;
diff --git a/sql/backends/monet5/Tests/pyapi32.stable.err
b/sql/backends/monet5/Tests/pyapi32.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi32.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'pyapi32` in directory 'sql/backends/monet5` itself:
+
+
+# 14:03:48 >
+# 14:03:48 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=34523" "--set"
"mapi_usock=/var/tmp/mtest-44806/.s.monetdb.34523" "--set" "monet_prompt="
"--forcemito" "--dbpath=/Users/myth/opt/var/MonetDB/mTests_sql_backends_monet5"
"--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 14:03:48 >
+
+# builtin opt gdk_dbpath = /Users/myth/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 = 34523
+# cmdline opt mapi_usock = /var/tmp/mtest-44806/.s.monetdb.34523
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/Users/myth/opt/var/MonetDB/mTests_sql_backends_monet5
+# cmdline opt embedded_r = yes
+# cmdline opt embedded_py = true
+# cmdline opt gdk_debug = 536870922
+
+# 14:03:49 >
+# 14:03:49 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-44806" "--port=34523"
+# 14:03:49 >
+
+
+# 14:03:49 >
+# 14:03:49 > "Done."
+# 14:03:49 >
+
diff --git a/sql/backends/monet5/Tests/pyapi32.stable.out
b/sql/backends/monet5/Tests/pyapi32.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi32.stable.out
@@ -0,0 +1,397 @@
+stdout of test 'pyapi32` in directory 'sql/backends/monet5` itself:
+
+
+# 14:03:48 >
+# 14:03:48 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=34523" "--set"
"mapi_usock=/var/tmp/mtest-44806/.s.monetdb.34523" "--set" "monet_prompt="
"--forcemito" "--dbpath=/Users/myth/opt/var/MonetDB/mTests_sql_backends_monet5"
"--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 14:03:48 >
+
+# MonetDB 5 server v11.24.0
+# This is an unreleased version
+# Serving database 'mTests_sql_backends_monet5', using 4 threads
+# Compiled for x86_64-apple-darwin15.5.0/64bit with 64bit OIDs and 128bit
integers dynamically linked
+# Found 8.000 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2016 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on
mapi:monetdb://Marks-MacBook-Pro.local:34523/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-44806/.s.monetdb.34523
+# MonetDB/SQL module loaded
+# MonetDB/Python module loaded
+# MonetDB/R module loaded
+
+Ready.
+# SQL catalog created, loading sql scripts once
+# loading sql script: 09_like.sql
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
+# loading sql script: 14_inet.sql
+# loading sql script: 15_querylog.sql
+# loading sql script: 16_tracelog.sql
+# loading sql script: 17_temporal.sql
+# loading sql script: 18_index.sql
+# loading sql script: 20_vacuum.sql
+# loading sql script: 21_dependency_functions.sql
+# loading sql script: 22_clients.sql
+# loading sql script: 23_skyserver.sql
+# loading sql script: 24_zorder.sql
+# loading sql script: 25_debug.sql
+# loading sql script: 26_sysmon.sql
+# loading sql script: 27_rejects.sql
+# loading sql script: 39_analytics.sql
+# loading sql script: 39_analytics_hge.sql
+# loading sql script: 40_json.sql
+# loading sql script: 40_json_hge.sql
+# loading sql script: 41_md5sum.sql
+# loading sql script: 45_uuid.sql
+# loading sql script: 46_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 72_fits.sql
+# loading sql script: 75_storagemodel.sql
+# loading sql script: 80_statistics.sql
+# loading sql script: 80_udf.sql
+# loading sql script: 80_udf_hge.sql
+# loading sql script: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+
+# 14:03:49 >
+# 14:03:49 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-44806" "--port=34523"
+# 14:03:49 >
+
+#START TRANSACTION;
+#CREATE FUNCTION pyapi32_gentbl() RETURNS TABLE(i TINYINT) LANGUAGE PYTHON {
+# return { 'i': numpy.arange(100) }
+#};
+#CREATE FUNCTION pyapi32_function(i INTEGER) RETURNS INTEGER LANGUAGE PYTHON {
+# return i * 2;
+#};
+#CREATE FUNCTION pyapi32_function_mapped(i INTEGER) RETURNS INTEGER LANGUAGE
PYTHON_MAP {
+# return i * 2;
+#};
+#CREATE TABLE integers AS SELECT * FROM pyapi32_gentbl() WITH DATA;
+#SELECT pyapi32_function(i) FROM integers;
+% sys.L # table_name
+% pyapi32_function_i # name
+% int # type
+% 3 # length
+[ 0 ]
+[ 2 ]
+[ 4 ]
+[ 6 ]
+[ 8 ]
+[ 10 ]
+[ 12 ]
+[ 14 ]
+[ 16 ]
+[ 18 ]
+[ 20 ]
+[ 22 ]
+[ 24 ]
+[ 26 ]
+[ 28 ]
+[ 30 ]
+[ 32 ]
+[ 34 ]
+[ 36 ]
+[ 38 ]
+[ 40 ]
+[ 42 ]
+[ 44 ]
+[ 46 ]
+[ 48 ]
+[ 50 ]
+[ 52 ]
+[ 54 ]
+[ 56 ]
+[ 58 ]
+[ 60 ]
+[ 62 ]
+[ 64 ]
+[ 66 ]
+[ 68 ]
+[ 70 ]
+[ 72 ]
+[ 74 ]
+[ 76 ]
+[ 78 ]
+[ 80 ]
+[ 82 ]
+[ 84 ]
+[ 86 ]
+[ 88 ]
+[ 90 ]
+[ 92 ]
+[ 94 ]
+[ 96 ]
+[ 98 ]
+[ 100 ]
+[ 102 ]
+[ 104 ]
+[ 106 ]
+[ 108 ]
+[ 110 ]
+[ 112 ]
+[ 114 ]
+[ 116 ]
+[ 118 ]
+[ 120 ]
+[ 122 ]
+[ 124 ]
+[ 126 ]
+[ 128 ]
+[ 130 ]
+[ 132 ]
+[ 134 ]
+[ 136 ]
+[ 138 ]
+[ 140 ]
+[ 142 ]
+[ 144 ]
+[ 146 ]
+[ 148 ]
+[ 150 ]
+[ 152 ]
+[ 154 ]
+[ 156 ]
+[ 158 ]
+[ 160 ]
+[ 162 ]
+[ 164 ]
+[ 166 ]
+[ 168 ]
+[ 170 ]
+[ 172 ]
+[ 174 ]
+[ 176 ]
+[ 178 ]
+[ 180 ]
+[ 182 ]
+[ 184 ]
+[ 186 ]
+[ 188 ]
+[ 190 ]
+[ 192 ]
+[ 194 ]
+[ 196 ]
+[ 198 ]
+#SELECT pyapi32_function(i) FROM integers WHERE i > 50;
+% sys.L # table_name
+% pyapi32_function_i # name
+% int # type
+% 3 # length
+[ 102 ]
+[ 104 ]
+[ 106 ]
+[ 108 ]
+[ 110 ]
+[ 112 ]
+[ 114 ]
+[ 116 ]
+[ 118 ]
+[ 120 ]
+[ 122 ]
+[ 124 ]
+[ 126 ]
+[ 128 ]
+[ 130 ]
+[ 132 ]
+[ 134 ]
+[ 136 ]
+[ 138 ]
+[ 140 ]
+[ 142 ]
+[ 144 ]
+[ 146 ]
+[ 148 ]
+[ 150 ]
+[ 152 ]
+[ 154 ]
+[ 156 ]
+[ 158 ]
+[ 160 ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list