I wrote an R script (for Windows) that created some dummy data and reproduced *three* of the five errors.  median and prod still do not work in my confidential data.  sign, stddev, and stddev_pop do not work when using the R script pasted below.  I created this the same way as before:

create table mtcars2 as select carb , count( case when gear in ( 3 , 4 ) then mpg end ) as gears from mtcars group by carb with data;

The starting data set I used is the `mtcars` data.frame that you can view if you open up R and type `mtcars`..  but I've pasted it below so you can see it's nothing special.

Here's the three EXPLAIN commands (run in mclient)..  below that, I've pasted R code to precisely re-create the database as I have it on my computer.   :)

When I add a *1 on the end of the count( case when gear in ( 3 , 4 ) then mpg end )*1 clause, I get the same errors..

Thanks!!!!



sql>explain select sign( gears ) from mtcars2;
TypeException:user.s1_2[16]:'bat.insert' undefined in: _53:any := bat.insert(_43
:bat[:oid,:int], _51:oid, _50:bte)
+-------------------------------------------------------------+
| mal                                                         |
+=============================================================+
| function user.s1_2{autoCommit=true}():void;                 |
|     X_15 := nil:bat[:oid,:wrd];                             |
| barrier X_36 := language.dataflow();                        |
|     X_2 := sql.mvc();                                       |
|     X_3:bat[:oid,:oid]  := sql.tid(X_2,"sys","mtcars2");    |
|     X_6 := sql.bind(X_2,"sys","mtcars2","gears",0);         |
|     (X_9,r1_9) := sql.bind(X_2,"sys","mtcars2","gears",2);  |
|     X_12 := sql.bind(X_2,"sys","mtcars2","gears",1);        |
|     X_14 := sql.delta(X_6,X_9,r1_9,X_12);                   |
|     X_15 := algebra.leftfetchjoin(X_3,X_14);                |
| exit X_36;                                                  |
|     X_41 := bat.reverse(X_15);                              |
|     X_43 := bat.new(nil:oid,nil:int);                       |
| barrier (X_47,X_48) := iterator.new(X_15);                  |
|     X_50 := calc.sign(X_48);                                |
|     X_51 := algebra.fetch(X_41,X_47);                       |
|     bat.insert(X_43,X_51,X_50);                             |
|     redo (X_47,X_48) := iterator.next(X_15);                |
| exit (X_47,X_48);                                           |
|     X_16:bat[:oid,:int]  := X_43;                           |
|     X_20 := sql.resultSet(1,1,X_16);                        |
|     sql.rsColumn(X_20,"sys.","sign_gears","int",32,0,X_16); |
|     X_25 := io.stdout();                                    |
|     sql.exportResult(X_25,X_20);                            |
| end s1_2;                                                   |
+-------------------------------------------------------------+
25 tuples (2.451ms)
sql>explain select stddev( gears ) from mtcars2;
SELECT: no such unary operator 'stddev(wrd)'
sql>explain select stddev_pop( gears ) from mtcars2;
SELECT: no such unary operator 'stddev_pop(wrd)'
sql>




============================
R code to reproduce mtcars2 in Windows  (shouldn't require much of a modification to get it working on other OSes)
============================


install.packages("MonetDB.R")

require(MonetDB.R)    # load the MonetDB.R package (connects r to a monet database)

batfile <-
    monetdb.server.setup(
                   
                    # set the path to the directory where the initialization batch file and all data will be stored
                    database.directory = "C:/My Directory/MonetDB" ,
                    # must be empty or not exist
                   
                    # find the main path to the monetdb installation program
                    monetdb.program.path = "C:/Program Files/MonetDB/MonetDB5" ,
                   
                    # choose a database name
                    dbname = "test" ,
                   
                    # choose a database port
                    # this port should not conflict with other monetdb databases
                    # on your local computer.  two databases with the same port number
                    # cannot be accessed at the same time
                    dbport = 50000
    )

dbname <- "test"
dbport <- 50000

# run the MonetDB server
pid <- monetdb.server.start( batfile )

# connect to the MonetDB server
monet.url <- paste0( "monetdb://localhost:" , dbport , "/" , dbname )
db <- dbConnect( MonetDB.R() , monet.url )

# write the example mtcars data.frame to monetdb
dbWriteTable( db , 'mtcars' , mtcars )

# create a new table the same way as before
dbSendUpdate( db , 'create table mtcars2 as select carb , count( case when gear in ( 3 , 4 ) then mpg end ) as gears from mtcars group by carb with data' )

# this works now, still doesn't work in my confidential data
dbGetQuery( db , 'select median( gears )  from mtcars2' )
dbGetQuery( db , 'select prod( gears ) from mtcars2' )

# this *does not* work
dbGetQuery( db , 'select sign( gears ) from mtcars2' )
dbGetQuery( db , 'select stddev( gears ) from mtcars2' )
dbGetQuery( db , 'select stddev_pop( gears ) from mtcars2' )



============================
here's the entire mtcars table
============================

                     mpg cyl  disp  hp drat    wt  qsec vs am gear carb
Mazda RX4           21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag       21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
Datsun 710          22.8   4 108.0  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive      21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout   18.7   8 360.0 175 3.15 3.440 17.02  0  0    3    2
Valiant             18.1   6 225.0 105 2.76 3.460 20.22  1  0    3    1
Duster 360          14.3   8 360.0 245 3.21 3.570 15.84  0  0    3    4
Merc 240D           24.4   4 146.7  62 3.69 3.190 20.00  1  0    4    2
Merc 230            22.8   4 140.8  95 3.92 3.150 22.90  1  0    4    2
Merc 280            19.2   6 167.6 123 3.92 3.440 18.30  1  0    4    4
Merc 280C           17.8   6 167.6 123 3.92 3.440 18.90  1  0    4    4
Merc 450SE          16.4   8 275.8 180 3.07 4.070 17.40  0  0    3    3
Merc 450SL          17.3   8 275.8 180 3.07 3.730 17.60  0  0    3    3
Merc 450SLC         15.2   8 275.8 180 3.07 3.780 18.00  0  0    3    3
Cadillac Fleetwood  10.4   8 472.0 205 2.93 5.250 17.98  0  0    3    4
Lincoln Continental 10.4   8 460.0 215 3.00 5.424 17.82  0  0    3    4
Chrysler Imperial   14.7   8 440.0 230 3.23 5.345 17.42  0  0    3    4
Fiat 128            32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1
Honda Civic         30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
Toyota Corolla      33.9   4  71.1  65 4.22 1.835 19.90  1  1    4    1
Toyota Corona       21.5   4 120.1  97 3.70 2.465 20.01  1  0    3    1
Dodge Challenger    15.5   8 318.0 150 2.76 3.520 16.87  0  0    3    2
AMC Javelin         15.2   8 304.0 150 3.15 3.435 17.30  0  0    3    2
Camaro Z28          13.3   8 350.0 245 3.73 3.840 15.41  0  0    3    4
Pontiac Firebird    19.2   8 400.0 175 3.08 3.845 17.05  0  0    3    2
Fiat X1-9           27.3   4  79.0  66 4.08 1.935 18.90  1  1    4    1
Porsche 914-2       26.0   4 120.3  91 4.43 2.140 16.70  0  1    5    2
Lotus Europa        30.4   4  95.1 113 3.77 1.513 16.90  1  1    5    2
Ford Pantera L      15.8   8 351.0 264 4.22 3.170 14.50  0  1    5    4
Ferrari Dino        19.7   6 145.0 175 3.62 2.770 15.50  0  1    5    6
Maserati Bora       15.0   8 301.0 335 3.54 3.570 14.60  0  1    5    8
Volvo 142E          21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2






On Tue, Apr 23, 2013 at 3:34 PM, Anthony Damico <ajdamico@gmail.com> wrote:

Am I right that this clause is embedded in a SQL statement like

create table ... as select ... <clause> ... from <table> with data;
where <table> has columns UNIQUE_ROW_IDENTIFIER and MY_CODE ?

Yes, precisely. :)