Changeset: a2b9e148eef0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a2b9e148eef0
Added Files:
        clients/R/Tests/dplyr-flights.R
        clients/R/Tests/dplyr-flights.reqtest
        clients/R/Tests/dplyr-flights.stable.err
        clients/R/Tests/dplyr-flights.stable.out
Modified Files:
        clients/R/Tests/All
        clients/R/Tests/dbapply.reqtests
        clients/R/Tests/install-dependencies.sh
        clients/R/Tests/survey.reqtests
Branch: default
Log Message:

R Connector: New dplyr test case based on dplyr documentation


diffs (286 lines):

diff --git a/clients/R/Tests/All b/clients/R/Tests/All
--- a/clients/R/Tests/All
+++ b/clients/R/Tests/All
@@ -2,6 +2,5 @@ HAVE_LIBR?install
 HAVE_LIBR?dbi
 HAVE_LIBR?survey
 HAVE_LIBR?dplyr
+HAVE_LIBR?dplyr-flights
 HAVE_LIBR?dbapply
-
-
diff --git a/clients/R/Tests/dbapply.reqtests b/clients/R/Tests/dbapply.reqtests
--- a/clients/R/Tests/dbapply.reqtests
+++ b/clients/R/Tests/dbapply.reqtests
@@ -1,1 +1,2 @@
 install
+dbi
diff --git a/clients/R/Tests/dplyr-flights.R b/clients/R/Tests/dplyr-flights.R
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/dplyr-flights.R
@@ -0,0 +1,128 @@
+ll <- NULL
+if (Sys.getenv("TSTTRGDIR") != "") {
+  ll <- paste0(Sys.getenv("TSTTRGDIR"),"/rlibdir")
+}
+ff <- textConnection("asdf", open="w")
+# hide output from connect and attach since it would blow up the test output
+# dangerous since it might hide useful warnings
+# so if things go south it might be a good idea to uncomment the cat(dd) below
+dd <- capture.output( suppressMessages ( {
+
+library(MonetDB.R,quietly=T,lib.loc=ll)
+library(dplyr,quietly=T)
+library(nycflights13,quietly=T)
+
+options(monetdb.profile=F)
+
+args <- commandArgs(trailingOnly = TRUE)
+dbport <- 50000
+dbname <- "mTests_clients_R"
+if (length(args) > 0) 
+  dbport <- args[[1]]
+if (length(args) > 1) 
+  dbname <- args[[2]]
+}))
+
+so <- function(x) {
+  print(dim(collect(head(x, 42))))
+}
+
+my_db <- src_monetdb(dbname=dbname, port=dbport, wait=T)
+if (!dbExistsTable(my_db$con , 'flights')) dbWriteTable( my_db$con , 'flights' 
, flights , csvdump=T, overwrite=T)
+flights <- tbl( my_db , 'flights')
+
+dim(flights)
+so(flights)
+so(filter(flights, month == 1, day == 1))
+so(filter(flights, month == 1 | month == 2))
+
+so(arrange(flights, year, month, day))
+so(arrange(flights, desc(arr_delay)))
+so(select(flights, year, month, day))
+so(select(flights, year:day))
+so(select(flights, -(year:day)))
+so(select(flights, tail_num = tailnum))
+so(rename(flights, tail_num = tailnum))
+so(distinct(select(flights, tailnum)))
+
+so(distinct(select(flights, origin, dest)))
+so(mutate(flights,
+  gain = arr_delay - dep_delay,
+  speed = distance / air_time * 60))
+
+
+so(mutate(flights,
+  gain = arr_delay - dep_delay,
+  gain_per_hour = (arr_delay - dep_delay) / (air_time / 60)
+))
+
+so(transmute(flights,
+  gain = arr_delay - dep_delay,
+  gain_per_hour = (arr_delay - dep_delay) / (air_time / 60)
+))
+
+so(summarise(flights,
+  delay = mean(dep_delay)))
+
+so(sample_n(flights, 10))
+so(sample_frac(flights, 0.01))
+
+# slice is not supported for reldbs as per dplyr doc
+# slice(flights, 1:10)
+# filter(flights, between(row_number(), 1, 10))
+
+destinations <- group_by(flights, dest)
+
+so(summarise(destinations,
+  planes = n_distinct(tailnum),
+  flights = n()
+))
+
+by_tailnum <- group_by(flights, tailnum)
+delay <- summarise(by_tailnum,
+  count = n(),
+  dist = mean(distance),
+  delay = mean(arr_delay))
+
+delay <- collect(filter(delay, count > 20, dist < 2000))
+so(delay)
+
+daily <- group_by(flights, year, month, day)
+so(per_day   <- summarise(daily, flights = n()))
+so(per_month <- summarise(per_day, flights = sum(flights)))
+so(per_yr  <- summarise(per_month, flights = sum(flights)))
+
+a1 <- group_by(flights, year, month, day)
+a2 <- select(a1, arr_delay, dep_delay)
+
+
+a3 <- summarise(a2,
+  arr = mean(arr_delay),
+  dep = mean(dep_delay))
+
+
+a4 <- filter(a3, arr > 30 | dep > 30)
+so(a4)
+
+so(filter(
+  summarise(
+    select(
+      group_by(flights, year, month, day),
+      arr_delay, dep_delay
+    ),
+    arr = mean(arr_delay),
+    dep = mean(dep_delay)
+  ),
+  arr > 30 | dep > 30
+))
+
+so(flights %>%
+  group_by(year, month, day) %>%
+  select(arr_delay, dep_delay) %>%
+  summarise(
+    arr = mean(arr_delay),
+    dep = mean(dep_delay)
+  ) %>%
+  filter(arr > 30 | dep > 30))
+
+print("SUCCESS")
\ No newline at end of file
diff --git a/clients/R/Tests/dplyr-flights.reqtest 
b/clients/R/Tests/dplyr-flights.reqtest
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/dplyr-flights.reqtest
@@ -0,0 +1,3 @@
+install
+dbi
+dplyr
diff --git a/clients/R/Tests/dplyr-flights.stable.err 
b/clients/R/Tests/dplyr-flights.stable.err
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/dplyr-flights.stable.err
@@ -0,0 +1,38 @@
+stderr of test 'dplyr-flights` in directory 'clients/R` itself:
+
+
+# 11:44:02 >  
+# 11:44:02 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=30588" "--set" 
"mapi_usock=/var/tmp/mtest-68891/.s.monetdb.30588" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/Users/hannes/monetdb-install/var/MonetDB/mTests_clients_R" "--set" 
"mal_listing=0" "--set" "embedded_r=yes"
+# 11:44:02 >  
+
+# builtin opt  gdk_dbpath = 
/Users/hannes/monetdb-install/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 = 30588
+# cmdline opt  mapi_usock = /var/tmp/mtest-68891/.s.monetdb.30588
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/Users/hannes/monetdb-install/var/MonetDB/mTests_clients_R
+# cmdline opt  mal_listing = 0
+# cmdline opt  embedded_r = yes
+# cmdline opt  gdk_debug = 536870922
+
+# 11:44:05 >  
+# 11:44:05 >  "R" "--vanilla" "--slave" "--args" "30588"
+# 11:44:05 >  
+
+Identifier(s) year, month, day, hour, minute are reserved SQL keywords and 
need to be quoted.
+
+# 11:44:15 >  
+# 11:44:15 >  "Done."
+# 11:44:15 >  
+
diff --git a/clients/R/Tests/dplyr-flights.stable.out 
b/clients/R/Tests/dplyr-flights.stable.out
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/dplyr-flights.stable.out
@@ -0,0 +1,65 @@
+stdout of test 'dplyr-flights` in directory 'clients/R` itself:
+
+
+# 11:44:02 >  
+# 11:44:02 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=30588" "--set" 
"mapi_usock=/var/tmp/mtest-68891/.s.monetdb.30588" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/Users/hannes/monetdb-install/var/MonetDB/mTests_clients_R" "--set" 
"mal_listing=0" "--set" "embedded_r=yes"
+# 11:44:02 >  
+
+# MonetDB 5 server v11.22.0
+# This is an unreleased version
+# Serving database 'mTests_clients_R', using 4 threads
+# Compiled for x86_64-apple-darwin14.4.0/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 16.000 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://dakar.da.cwi.nl:30588/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-68891/.s.monetdb.30588
+# MonetDB/GIS module loaded
+# Start processing logs sql/sql_logs version 52200
+# Start reading the write-ahead log 'sql_logs/sql/log.5'
+# Finished reading the write-ahead log 'sql_logs/sql/log.5'
+# Finished processing logs sql/sql_logs
+# MonetDB/SQL module loaded
+# MonetDB/R   module loaded
+
+Ready.
+
+# 11:44:05 >  
+# 11:44:05 >  "R" "--vanilla" "--slave" "--args" "30588"
+# 11:44:05 >  
+
+[1] TRUE
+[1] 336776     16
+[1] 42 16
+[1] 42 16
+[1] 42 16
+[1] 42 16
+[1] 42 16
+[1] 42  3
+[1] 42  3
+[1] 42 13
+[1] 42  1
+[1] 42 16
+[1] 42  1
+[1] 42  2
+[1] 42 18
+[1] 42 18
+[1] 42  2
+[1] 1 1
+[1] 10 16
+[1] 42 16
+[1] 42  3
+[1] 42  4
+[1] 42  4
+[1] 12  3
+[1] 1 2
+[1] 42  5
+[1] 42  5
+[1] 42  5
+[1] "SUCCESS"
+
+# 11:44:15 >  
+# 11:44:15 >  "Done."
+# 11:44:15 >  
+
diff --git a/clients/R/Tests/install-dependencies.sh 
b/clients/R/Tests/install-dependencies.sh
--- a/clients/R/Tests/install-dependencies.sh
+++ b/clients/R/Tests/install-dependencies.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
 R --vanilla --quiet -e 'dir.create(unlist(strsplit(Sys.getenv("R_LIBS_USER"), 
.Platform$path.sep))[1L], recursive = TRUE, showWarnings=F)'
-R --vanilla --quiet -e 
"install.packages(c('dplyr','survey','sqlsurvey','DBI','digest','Lahman'),repos=c('http://download.r-forge.r-project.org','http://cran.rstudio.com/'),type='source')"
+R --vanilla --quiet -e 
"install.packages(c('dplyr','survey','sqlsurvey','DBI','digest','Lahman','nycflights13'),repos=c('http://download.r-forge.r-project.org','http://cran.rstudio.com/'),type='source')"
diff --git a/clients/R/Tests/survey.reqtests b/clients/R/Tests/survey.reqtests
--- a/clients/R/Tests/survey.reqtests
+++ b/clients/R/Tests/survey.reqtests
@@ -1,1 +1,2 @@
 install
+dbi
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to