Update of /cvsroot/monetdb/sql/src/test/Tests
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22224

Modified Files:
        All 
Added Files:
        median_stdev.sql median_stdev.stable.err 
        median_stdev.stable.out 
Log Message:
add the example median and stdev queries (also tests the row_number windowing 
function)


--- NEW FILE: median_stdev.stable.err ---
stderr of test 'median_stdev` in directory 'src/test` itself:


# 20:38:18 >  
# 20:38:18 >   mserver5 
"--config=/ufs/niels/scratch/monetdb/Linux-x86_64/etc/monetdb5.conf" --debug=10 
--set 
"monet_mod_path=/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/bin"
 --set "gdk_dbfarm=/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/dbfarm" 
--set 
"sql_logdir=/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/sql_logs"  
--set mapi_open=true --set xrpc_open=true --set mapi_port=36991 --set 
xrpc_port=46066 --set monet_prompt= --trace  "--dbname=mTests_src_test" --set 
mal_listing=0 "--dbinit= include sql;" ; echo ; echo Over..
# 20:38:18 >  

# builtin opt   gdk_arch = 64bitx86_64-unknown-linux-gnu
# builtin opt   gdk_version = 1.23.0
# builtin opt   monet_pid = 12208
# builtin opt   prefix = /ufs/niels/scratch/monetdb/Linux-x86_64
# builtin opt   exec_prefix = ${prefix}
# builtin opt   gdk_dbname = tst
# builtin opt   gdk_dbfarm = ${prefix}/var/MonetDB
# builtin opt   gdk_debug = 8
# builtin opt   gdk_mem_bigsize = 262144
# builtin opt   gdk_alloc_map = yes
# builtin opt   gdk_mem_pagebits = 14
# builtin opt   gdk_vmtrim = yes
# builtin opt   monet_admin = adm
# builtin opt   monet_prompt = >
# builtin opt   monet_welcome = yes
# builtin opt   monet_mod_path = 
${exec_prefix}/lib/MonetDB:${exec_prefix}/lib/bin
# builtin opt   monet_daemon = yes
# builtin opt   host = localhost
# builtin opt   mapi_port = 50000
# builtin opt   mapi_noheaders = no
# builtin opt   mapi_debug = 0
# builtin opt   mapi_clients = 2
# builtin opt   sql_debug = 0
# builtin opt   sql_logdir = ${prefix}/var/MonetDB/sql_logs
# builtin opt   xquery_logdir = ${prefix}/var/MonetDB/xquery_logs
# builtin opt   standoff_ns = http://monetdb.cwi.nl/standoff
# builtin opt   standoff_start = start
# builtin opt   standoff_end = end
# config opt    prefix = /ufs/niels/scratch/monetdb/Linux-x86_64
# config opt    config = ${prefix}/etc/monetdb5.conf
# config opt    prefix = /ufs/niels/scratch/monetdb/Linux-x86_64
# config opt    exec_prefix = ${prefix}
# config opt    gdk_dbfarm = ${prefix}/var/MonetDB5/dbfarm
# config opt    gdk_dbname = demo
# config opt    gdk_alloc_map = no
# config opt    gdk_embedded = no
# config opt    gdk_debug = 0
# config opt    monet_mod_path = 
${exec_prefix}/lib/MonetDB5:${exec_prefix}/lib/MonetDB5/lib:${exec_prefix}/lib/MonetDB5/bin
# config opt    monet_daemon = no
# config opt    monet_welcome = yes
# config opt    mero_msglog = ${prefix}/var/log/merovingian.log
# config opt    mero_errlog = ${prefix}/var/log/merovingian.log
# config opt    mero_timeinterval = 600
# config opt    mero_pidfile = ${prefix}/var/run/merovingian.pid
# config opt    mero_exittimeout = 7
# config opt    mero_doproxy = yes
# config opt    mero_discoveryttl = 600
# config opt    mal_init = ${exec_prefix}/lib/MonetDB5/mal_init.mal
# config opt    mal_listing = 15
# config opt    checkpoint_dir = ${prefix}/var/MonetDB5/chkpnt
# config opt    mapi_port = 50000
# config opt    mapi_open = false
# config opt    sql_debug = 0
# config opt    sql_logdir = ${prefix}/var/MonetDB5/sql_logs
# config opt    sql_init = ${exec_prefix}/lib/MonetDB5/sql_init.sql
# cmdline opt   config = 
/ufs/niels/scratch/monetdb/Linux-x86_64/etc/monetdb5.conf
# cmdline opt   monet_mod_path = 
/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/bin
# cmdline opt   gdk_dbfarm = 
/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/dbfarm
# cmdline opt   sql_logdir = 
/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/sql_logs
# cmdline opt   mapi_open = true
# cmdline opt   xrpc_open = true
# cmdline opt   mapi_port = 36991
# cmdline opt   xrpc_port = 46066
# cmdline opt   monet_prompt = 
# cmdline opt   gdk_dbname = mTests_src_test
# cmdline opt   mal_listing = 0
# cmdline opt   gdk_debug = 10
#warning: please don't forget to set your vault key!
#(see /ufs/niels/scratch/monetdb/Linux-x86_64/etc/monetdb5.conf)

# 20:38:18 >  
# 20:38:18 >  mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36991 
# 20:38:18 >  


# 20:38:18 >  
# 20:38:18 >  Done.
# 20:38:18 >  


U All
Index: All
===================================================================
RCS file: /cvsroot/monetdb/sql/src/test/Tests/All,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- All 6 Mar 2008 08:33:16 -0000       1.51
+++ All 20 Jun 2008 18:40:56 -0000      1.52
@@ -93,3 +93,4 @@
 load_with_offset
 copy_into
 antiselect
+median_stdev

--- NEW FILE: median_stdev.sql ---
CREATE TABLE sampleData ( groupID int, numValue int );
INSERT INTO sampleData VALUES ( 1,   1 );
INSERT INTO sampleData VALUES ( 1,   2 );
INSERT INTO sampleData VALUES ( 1,   6 );
INSERT INTO sampleData VALUES ( 1,  16 );
INSERT INTO sampleData VALUES ( 1,   7 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,  11 );
INSERT INTO sampleData VALUES ( 3,  10 );
INSERT INTO sampleData VALUES ( 3,  17 );
INSERT INTO sampleData VALUES ( 3,  52 );
INSERT INTO sampleData VALUES ( 3,  66 );
INSERT INTO sampleData VALUES ( 4,  18 );
INSERT INTO sampleData VALUES ( 5,   0 );
INSERT INTO sampleData VALUES ( 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;

SELECT R.groupID, sqrt(SUM((R.n-G.a)*(R.n-G.a))/count(*)) AS stdev
FROM
(    SELECT GroupID, NumValue as n
    FROM sampleData
) R
INNER JOIN
(    SELECT GroupID, AVG(numValue) as a
    FROM sampleData
    GROUP BY GroupID
) G
ON R.GroupID = G.GroupID 
GROUP BY R.groupID;

drop table sampleData;

--- NEW FILE: median_stdev.stable.out ---
stdout of test 'median_stdev` in directory 'src/test` itself:


# 20:38:18 >  
# 20:38:18 >   mserver5 
"--config=/ufs/niels/scratch/monetdb/Linux-x86_64/etc/monetdb5.conf" --debug=10 
--set 
"monet_mod_path=/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/monetdb/Linux-x86_64/lib/MonetDB5/bin"
 --set "gdk_dbfarm=/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/dbfarm" 
--set 
"sql_logdir=/ufs/niels/scratch/monetdb/Linux-x86_64/var/MonetDB5/sql_logs"  
--set mapi_open=true --set xrpc_open=true --set mapi_port=36991 --set 
xrpc_port=46066 --set monet_prompt= --trace  "--dbname=mTests_src_test" --set 
mal_listing=0 "--dbinit= include sql;" ; echo ; echo Over..
# 20:38:18 >  

# MonetDB server v5.5.0, based on kernel v1.25.0
# Serving database 'mTests_src_test'
# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically linked
# Copyright (c) 1993-2008 CWI, all rights reserved
# Visit http://monetdb.cwi.nl/ for further information
# Listening for connection requests on mapi:monetdb://alf.ins.cwi.nl:36991/
# MonetDB/SQL module v2.23.0 loaded

Ready.
#function user.main():void;
#    clients.quit();
#end main;

Over..

# 20:38:18 >  
# 20:38:18 >  mclient -lsql -umonetdb -Pmonetdb --host=alf --port=36991 
# 20:38:18 >  

[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
[ 1     ]
% sys.r,        . # table_name
% groupid,      medianvalue # name
% int,  double # type
% 1,    22 # length
[ 1,    6       ]
[ 2,    5       ]
[ 3,    34.5    ]
[ 4,    18      ]
[ 5,    0       ]
% sys.r,        sys. # table_name
% groupid,      stdev # name
% int,  double # type
% 1,    22 # length
[ 1,    5.3141321022345691      ]
[ 2,    2.598076211353316       ]
[ 3,    23.41340428045439       ]
[ 4,    0       ]
[ 5,    0       ]

# 20:38:18 >  
# 20:38:18 >  Done.
# 20:38:18 >  



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to