Changeset: ab919d359405 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ab919d359405
Added Files:
        sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.sql
        
sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.err
        
sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.out
Modified Files:
        sql/test/BugTracker-2019/Tests/All
Branch: Nov2019
Log Message:

Add test for bug 6726
Note that query: SELECT value, python_aggregate(groupnr) FROM grouped_ints 
GROUP BY value;
does not give the correct answer. It only returned two rows instead of 5.


diffs (200 lines):

diff --git a/sql/test/BugTracker-2019/Tests/All 
b/sql/test/BugTracker-2019/Tests/All
--- a/sql/test/BugTracker-2019/Tests/All
+++ b/sql/test/BugTracker-2019/Tests/All
@@ -21,6 +21,7 @@ select_window_function_and_asterisk.Bug-
 KNOWNFAIL?disallow_duplicate_column_aliases.Bug-6723
 prepare-types.Bug-6724
 prepare-non-existing-function.Bug-6725
+HAVE_LIBPY3?python-aggregate-no-groups.Bug-6726
 select-distinct.Bug-6728
 table-duplicate-column.Bug-6729
 view-too-few-rows.Bug-6736
diff --git 
a/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.sql 
b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.sql
@@ -0,0 +1,32 @@
+CREATE AGGREGATE python_aggregate(val INTEGER)
+RETURNS INTEGER
+LANGUAGE PYTHON {
+    try:
+        unique = numpy.unique(aggr_group)
+        x = numpy.zeros(shape=(unique.size))
+        for i in range(0, unique.size):
+            x[i] = numpy.sum(val[aggr_group==unique[i]])
+    except NameError:
+        # aggr_group doesn't exist. no groups, aggregate on all data
+        x = numpy.sum(val)
+    return(x)
+};
+
+CREATE TABLE grouped_ints(value INTEGER, groupnr INTEGER);
+INSERT INTO grouped_ints VALUES (1, 0), (2, 1), (3, 0), (4, 1), (5, 0);
+SELECT groupnr, python_aggregate(value) FROM grouped_ints GROUP BY groupnr;
+SELECT value, python_aggregate(groupnr) FROM grouped_ints GROUP BY value;
+SELECT python_aggregate(groupnr) FROM grouped_ints;
+SELECT python_aggregate(value) FROM grouped_ints;
+DROP TABLE grouped_ints;
+
+CREATE TABLE grouped_ints(value INTEGER, groupnr INTEGER, groupnr2 INTEGER);
+INSERT INTO grouped_ints VALUES (1, 0, 0), (2, 0, 0), (3, 0, 1), (4, 0, 1), 
(5, 1, 0), (6, 1, 0), (7, 1, 1), (8, 1, 1);
+SELECT groupnr, groupnr2, python_aggregate(value) FROM grouped_ints GROUP BY 
groupnr, groupnr2;
+SELECT python_aggregate(groupnr) FROM grouped_ints;
+SELECT python_aggregate(groupnr2) FROM grouped_ints;
+SELECT python_aggregate(value) FROM grouped_ints;
+DROP TABLE grouped_ints;
+
+DROP AGGREGATE python_aggregate(INTEGER);
+
diff --git 
a/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.err 
b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.err
@@ -0,0 +1,32 @@
+stderr of test 'python-aggregate-no-groups.Bug-6726` in directory 
'sql/test/BugTracker-2019` itself:
+
+
+# 15:34:36 >  
+# 15:34:36 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31329" "--set" 
"mapi_usock=/var/tmp/mtest-13339/.s.monetdb.31329" "--forcemito" 
"--dbpath=/home/dinther/dev/dev/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019"
 "--set" "embedded_r=yes" "--set" "embedded_py=2" "--set" "embedded_c=true"
+# 15:34:36 >  
+
+# builtin opt  gdk_dbpath = 
/home/dinther/dev/dev/INSTALL/var/monetdb5/dbfarm/demo
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_ipv6 = 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 = 31329
+# cmdline opt  mapi_usock = /var/tmp/mtest-13339/.s.monetdb.31329
+# cmdline opt  gdk_dbpath = 
/home/dinther/dev/dev/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019
+# cmdline opt  embedded_r = yes
+# cmdline opt  embedded_py = 2
+# cmdline opt  embedded_c = true
+
+# 15:34:36 >  
+# 15:34:36 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13339" "--port=31329"
+# 15:34:36 >  
+
+
+# 15:35:48 >  
+# 15:35:48 >  "Done."
+# 15:35:48 >  
+
diff --git 
a/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.out 
b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2019/Tests/python-aggregate-no-groups.Bug-6726.stable.out
@@ -0,0 +1,110 @@
+stdout of test 'python-aggregate-no-groups.Bug-6726` in directory 
'sql/test/BugTracker-2019` itself:
+
+
+# 15:34:36 >  
+# 15:34:36 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31329" "--set" 
"mapi_usock=/var/tmp/mtest-13339/.s.monetdb.31329" "--forcemito" 
"--dbpath=/home/dinther/dev/dev/INSTALL/var/MonetDB/mTests_sql_test_BugTracker-2019"
 "--set" "embedded_r=yes" "--set" "embedded_py=2" "--set" "embedded_c=true"
+# 15:34:36 >  
+
+# MonetDB 5 server v11.35.4 (hg id: e54cc7e9164a)
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2019', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 31.243 GiB available main-memory of which we use 25.463 GiB
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2019 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://localhost.localdomain:31329/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-13339/.s.monetdb.31329
+# MonetDB/GIS module loaded
+# SQL catalog created, loading sql scripts once
+# MonetDB/SQL module loaded
+# MonetDB/Python2 module loaded
+# MonetDB/R   module loaded
+
+# 15:34:36 >  
+# 15:34:36 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13339" "--port=31329"
+# 15:34:36 >  
+
+#CREATE AGGREGATE python_aggregate(val INTEGER)
+#RETURNS INTEGER
+#LANGUAGE PYTHON {
+#    try:
+#        unique = numpy.unique(aggr_group)
+#        x = numpy.zeros(shape=(unique.size))
+#        for i in range(0, unique.size):
+#            x[i] = numpy.sum(val[aggr_group==unique[i]])
+#    except NameError:
+#        # aggr_group doesn't exist. no groups, aggregate on all data
+#        x = numpy.sum(val)
+#    return(x)
+#};
+#CREATE TABLE grouped_ints(value INTEGER, groupnr INTEGER);
+#INSERT INTO grouped_ints VALUES (1, 0), (2, 1), (3, 0), (4, 1), (5, 0);
+[ 5    ]
+#SELECT groupnr, python_aggregate(value) FROM grouped_ints GROUP BY groupnr;
+% sys.grouped_ints,    sys.L1 # table_name
+% groupnr,     L1 # name
+% int, int # type
+% 1,   1 # length
+[ 0,   9       ]
+[ 1,   6       ]
+#SELECT value, python_aggregate(groupnr) FROM grouped_ints GROUP BY value;
+% sys.grouped_ints,    sys.L1 # table_name
+% value,       L1 # name
+% int, int # type
+% 1,   1 # length
+[ 1,   0       ]
+[ 2,   1       ]
+[ 3,   0       ]
+[ 4,   1       ]
+[ 5,   0       ]
+#SELECT python_aggregate(groupnr) FROM grouped_ints;
+% sys.L2 # table_name
+% L2 # name
+% int # type
+% 1 # length
+[ 2    ]
+#SELECT python_aggregate(value) FROM grouped_ints;
+% sys.L2 # table_name
+% L2 # name
+% int # type
+% 2 # length
+[ 15   ]
+#DROP TABLE grouped_ints;
+#CREATE TABLE grouped_ints(value INTEGER, groupnr INTEGER, groupnr2 INTEGER);
+#INSERT INTO grouped_ints VALUES (1, 0, 0), (2, 0, 0), (3, 0, 1), (4, 0, 1), 
(5, 1, 0), (6, 1, 0), (7, 1, 1), (8, 1, 1);
+[ 8    ]
+#SELECT groupnr, groupnr2, python_aggregate(value) FROM grouped_ints GROUP BY 
groupnr, groupnr2;
+% sys.grouped_ints,    sys.grouped_ints,       sys.L1 # table_name
+% groupnr,     groupnr2,       L1 # name
+% int, int,    int # type
+% 1,   1,      2 # length
+[ 0,   0,      3       ]
+[ 0,   1,      7       ]
+[ 1,   0,      11      ]
+[ 1,   1,      15      ]
+#SELECT python_aggregate(groupnr) FROM grouped_ints;
+% sys.L2 # table_name
+% L2 # name
+% int # type
+% 1 # length
+[ 4    ]
+#SELECT python_aggregate(groupnr2) FROM grouped_ints;
+% sys.L2 # table_name
+% L2 # name
+% int # type
+% 1 # length
+[ 4    ]
+#SELECT python_aggregate(value) FROM grouped_ints;
+% sys.L2 # table_name
+% L2 # name
+% int # type
+% 2 # length
+[ 36   ]
+#DROP TABLE grouped_ints;
+#DROP AGGREGATE python_aggregate(INTEGER);
+
+# 15:34:37 >  
+# 15:34:37 >  "Done."
+# 15:34:37 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to