Changeset: c6fe5acf0f8e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c6fe5acf0f8e
Modified Files:
monetdb5/optimizer/opt_mergetable.c
sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
sql/test/Tests/median_stdev.sql
sql/test/Tests/median_stdev.stable.out
sql/test/Tests/trace.stable.out
Branch: default
Log Message:
fix problem with median and mergetable optimizer
diffs (116 lines):
diff --git a/monetdb5/optimizer/opt_mergetable.c
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -1967,8 +1967,11 @@ OPTmergetableImplementation(Client cntxt
actions++;
continue;
}
- if (match == 3 && getModuleId(p) == aggrRef && p->argc == 4)
- assert(0);
+ /* median */
+ if (match == 3 && getModuleId(p) == aggrRef && p->argc == 4) {
+ error++;
+ goto fail;
+ }
/*
* @-
* Aggregate handling is a prime target for optimization.
diff --git
a/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
b/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
--- a/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
+++ b/sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
@@ -80,12 +80,13 @@ stderr of test 'cardinality_violation.SF
# 21:00:43 > mclient -lsql -umonetdb -Pmonetdb --host=alf --port=38808
# 21:00:43 >
-MAPI = monetdb@niels:39633
+MAPI = monetdb@niels:35277
QUERY = select * from env() as env where name = ( select 'prefix' from env()
as env );
ERROR = !cardinality violation (21>1)
-MAPI = monetdb@niels:39633
+MAPI = monetdb@niels:35277
QUERY = select * from columns where name = (select columns.name from _tables,
columns where _tables.id = columns.table_id);
-ERROR = !cardinality violation (300>1)
+ERROR = !cardinality violation (299>1)
+
# 21:00:43 >
# 21:00:43 > Done.
diff --git a/sql/test/Tests/median_stdev.sql b/sql/test/Tests/median_stdev.sql
--- a/sql/test/Tests/median_stdev.sql
+++ b/sql/test/Tests/median_stdev.sql
@@ -20,9 +20,9 @@ INSERT INTO sampleData VALUES ( 5, 0 )
SELECT count(*) from sampleData;
-- Median tests
-SELECT median(numValue) FROM sampleData; -- should return 6.5 (or 6, or 7)
+SELECT median(numValue) FROM sampleData; -- should return 6
SELECT median(groupID) FROM sampleData; -- should return 2
-SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID; -- should
return (6, 5, 34.5, 18, 0)
+SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID; -- should
return (6, 5, 17, 18, 0)
SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
diff --git a/sql/test/Tests/median_stdev.stable.out
b/sql/test/Tests/median_stdev.stable.out
--- a/sql/test/Tests/median_stdev.stable.out
+++ b/sql/test/Tests/median_stdev.stable.out
@@ -39,6 +39,48 @@ Ready.
[ 1 ]
[ 1 ]
[ 1 ]
+#INSERT INTO sampleData VALUES ( 5, 0 );
+[ 1 ]
+#SELECT count(*) from sampleData;
+% sys.sampledata # table_name
+% L1 # name
+% wrd # type
+% 2 # length
+[ 17 ]
+#SELECT median(numValue) FROM sampleData; -- should return 6.5 (or 6, or 7)
+% sys.sampledata # table_name
+% L1 # name
+% int # type
+% 1 # length
+[ 6 ]
+#SELECT median(groupID) FROM sampleData; -- should return 2
+% sys.sampledata # table_name
+% L1 # name
+% int # type
+% 1 # length
+[ 2 ]
+#SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID; -- should
return (6, 5, 34.5, 18, 0)
+% sys.sampledata, sys.sampledata # table_name
+% groupid, L1 # name
+% int, int # type
+% 1, 2 # length
+[ 1, 6 ]
+[ 2, 5 ]
+[ 3, 17 ]
+[ 4, 18 ]
+[ 5, 0 ]
+#SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
+#FROM
+#( SELECT GroupID, numValue, ROW_NUMBER() OVER(PARTITION BY groupID ORDER
BY NumValue) AS rowno
+# FROM sampleData
+#) R
+#INNER JOIN
+#( SELECT GroupID, 1+count(*) as N
+# FROM sampleData
+# GROUP BY GroupID
+#) G
+#ON R.GroupID = G.GroupID AND R.rowNo BETWEEN N/2 AND N/2+N%2
+#GROUP BY R.groupID;
% sys.r, . # table_name
% groupid, medianvalue # name
% int, double # type
diff --git a/sql/test/Tests/trace.stable.out b/sql/test/Tests/trace.stable.out
--- a/sql/test/Tests/trace.stable.out
+++ b/sql/test/Tests/trace.stable.out
@@ -35,7 +35,7 @@ Ready.
% L1 # name
% wrd # type
% 2 # length
-[ 17 ]
+[ 16 ]
# 11:14:41 >
# 11:14:41 > Done.
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list