Changeset: 8ed2c926eea5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8ed2c926eea5
Modified Files:
clients/R/MonetDB.R/R/dbi.R
clients/R/MonetDB.R/R/dplyr.R
clients/R/Tests/dplyr.R
clients/R/Tests/dplyr.stable.err
clients/R/Tests/dplyr.stable.out
Branch: Oct2014
Log Message:
R Connector: dplyr test case should run
Unterschiede (gekürzt von 1178 auf 300 Zeilen):
diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R
--- a/clients/R/MonetDB.R/R/dbi.R
+++ b/clients/R/MonetDB.R/R/dbi.R
@@ -209,8 +209,9 @@ setMethod("dbListFields", "MonetDBConnec
})
setMethod("dbExistsTable", "MonetDBConnection", def=function(conn, name, ...) {
- #TODO: make this work with more cases
- tolower(name) %in% tolower(dbListTables(conn,sys_tables=T))
+ # TODO: this is evil...
+ return(tolower(gsub("(^\"|\"$)","",as.character(name))) %in%
+ tolower(dbListTables(conn,sys_tables=T)))
})
setMethod("dbGetException", "MonetDBConnection", def=function(conn, ...) {
diff --git a/clients/R/MonetDB.R/R/dplyr.R b/clients/R/MonetDB.R/R/dplyr.R
--- a/clients/R/MonetDB.R/R/dplyr.R
+++ b/clients/R/MonetDB.R/R/dplyr.R
@@ -40,7 +40,8 @@ db_query_rows.MonetDBConnection <- funct
}
db_insert_into.MonetDBConnection <- function(con, table, values, ...) {
- dbWriteTable(con,table,values,append=T,transaction=F,csvdump=T)
+ dbWriteTable(con,dbQuoteIdentifier(con,table),values,
+ append=T,transaction=F,csvdump=T)
}
db_save_query.MonetDBConnection <- function(con, sql, name, temporary = TRUE,
@@ -61,7 +62,6 @@ db_analyze.MonetDBConnection <- function
}
sql_subquery.MonetDBConnection <- function(con, sql, name = unique_name(),
...) {
- print(str(sql))
if (is.ident(sql)) return(sql)
monetdb_check_subquery(sql)
build_sql("(", sql, ") AS ", ident(name), con = con)
diff --git a/clients/R/Tests/dplyr.R b/clients/R/Tests/dplyr.R
--- a/clients/R/Tests/dplyr.R
+++ b/clients/R/Tests/dplyr.R
@@ -1,11 +1,10 @@
-library(dplyr,quietly=T)
ll <- NULL
if (Sys.getenv("TSTTRGDIR") != "") {
ll <- paste0(Sys.getenv("TSTTRGDIR"),"/rlibdir")
}
library(MonetDB.R,quietly=T,lib.loc=ll)
+library(dplyr,quietly=T)
library(Lahman,quietly=T)
-options(monetdb.debug.query=T)
args <- commandArgs(trailingOnly = TRUE)
dbport <- 50000
@@ -16,18 +15,19 @@ if (length(args) > 0)
# old way
if (exists("lahman_monetdb")) {
# overwrite all args because lahman_monetdb sets a default arg in the
first pos.
- srct <- function() lahman_monetdb(host="localhost", dbname=dbname,
port=dbport ,
+ dps <- lahman_monetdb(host="localhost", dbname=dbname, port=dbport ,
user="monetdb",password="monetdb",timeout=100,wait=T,language="sql")
# new way
} else {
- srct <- function() src_monetdb(dbname=dbname, port=dbport)
- copy_lahman(srct())
+ dps <- src_monetdb(dbname=dbname, port=dbport)
+ copy_lahman(dps)
}
# the remainder is pretty much the example from the manpage.
+
# Methods -------------------------------------------------------------------
-batting <- tbl(srct(), "Batting")
+batting <- tbl(dps, "Batting")
dim(batting)
colnames(batting)
head(batting)
@@ -35,8 +35,8 @@ head(batting)
# co* verbs
cc <- collapse(batting)
cc <- collect(batting)
-cc <- compute(batting)
-head(cc)
+# cc <- compute(batting)
+# head(cc)
# Data manipulation verbs ---------------------------------------------------
@@ -67,12 +67,11 @@ stints <- summarise(per_year, stints = m
filter(stints, stints > 3)
summarise(stints, max(stints))
-jsrc <- srct()
# Joins ---------------------------------------------------------------------
-player_info <- select(tbl(jsrc, "Master"), playerID, hofID,
+player_info <- select(tbl(dps, "Master"), playerID,
birthYear)
-hof <- select(filter(tbl(jsrc, "HallOfFame"), inducted == "Y"),
- hofID, votedBy, category)
+hof <- select(filter(tbl(dps, "HallOfFame"), inducted == "Y"),
+ playerID, votedBy, category)
# Match players and their hall of fame data
inner_join(player_info, hof)
@@ -87,7 +86,7 @@ anti_join(player_info, hof)
# Arbitrary SQL -------------------------------------------------------------
# You can also provide sql as is, using the sql function:
-batting2008 <- tbl(srct(),
+batting2008 <- tbl(dps,
sql('SELECT * FROM "Batting" WHERE "yearID" = 2008'))
batting2008
diff --git a/clients/R/Tests/dplyr.stable.err b/clients/R/Tests/dplyr.stable.err
--- a/clients/R/Tests/dplyr.stable.err
+++ b/clients/R/Tests/dplyr.stable.err
@@ -33,6 +33,10 @@ stderr of test 'dplyr` in directory 'cli
Attaching package: âdplyrâ
+The following object is masked from âpackage:MonetDB.Râ:
+
+ src_monetdb
+
The following objects are masked from âpackage:statsâ:
filter, lag
@@ -41,18 +45,37 @@ The following objects are masked from â
intersect, setdiff, setequal, union
+Creating table: AllstarFull
+Creating table: Appearances
+Creating table: AwardsManagers
+Creating table: AwardsPlayers
+Creating table: AwardsShareManagers
+Creating table: AwardsSharePlayers
+Creating table: Batting
+Creating table: BattingPost
+Creating table: Fielding
+Creating table: FieldingOF
+Creating table: FieldingPost
+Creating table: HallOfFame
+Creating table: LahmanData
+Creating table: Managers
+Creating table: ManagersHalf
+Creating table: Master
+Creating table: Pitching
+Creating table: PitchingPost
+Creating table: Salaries
+Creating table: Schools
+Creating table: SchoolsPlayers
+Creating table: SeriesPost
+Creating table: Teams
+Creating table: TeamsFranchises
+Creating table: TeamsHalf
+Joining by: "playerID"
+Joining by: "playerID"
+Joining by: "playerID"
+Joining by: "playerID"
-Attaching package: âMonetDB.Râ
+# 15:33:59 >
+# 15:33:59 > "Done."
+# 15:33:59 >
-The following object is masked from âpackage:dplyrâ:
-
- src_monetdb
-
-Error in .local(drv, ...) : argument is missing, with no default
-Calls: tbl ... dbi_connect.DBIDriver -> dbConnect -> .valueClassTest -> is ->
is -> .local
-Execution halted
-
-# 10:34:57 >
-# 10:34:57 > "Done."
-# 10:34:57 >
-
diff --git a/clients/R/Tests/dplyr.stable.out b/clients/R/Tests/dplyr.stable.out
--- a/clients/R/Tests/dplyr.stable.out
+++ b/clients/R/Tests/dplyr.stable.out
@@ -20,12 +20,991 @@ stdout of test 'dplyr` in directory 'cli
Ready.
-# 14:31:12 >
-# 14:31:12 > "R" "--vanilla" "--slave" "--args" "32629"
-# 14:31:12 >
+# 16:01:03 >
+# 16:01:03 > "R" "--vanilla" "--slave" "--args" "36798"
+# 16:01:03 >
+[1] 97889 24
+ [1] "playerID" "yearID" "stint" "teamID" "lgID" "G"
+ [7] "G_batting" "AB" "R" "H" "X2B" "X3B"
+[13] "HR" "RBI" "SB" "CS" "BB" "SO"
+[19] "IBB" "HBP" "SH" "SF" "GIDP" "G_old"
+ playerID yearID stint teamID lgID G G_batting AB R H X2B X3B HR RBI SB CS
+1 aardsda01 2004 1 SFN NL 11 11 0 0 0 0 0 0 0 0 0
+2 aardsda01 2006 1 CHN NL 45 43 2 0 0 0 0 0 0 0 0
+3 aardsda01 2007 1 CHA AL 25 2 0 0 0 0 0 0 0 0 0
+4 aardsda01 2008 1 BOS AL 47 5 1 0 0 0 0 0 0 0 0
+5 aardsda01 2009 1 SEA AL 73 3 0 0 0 0 0 0 0 0 0
+6 aardsda01 2010 1 SEA AL 53 4 0 0 0 0 0 0 0 0 0
+ BB SO IBB HBP SH SF GIDP G_old
+1 0 0 0 0 0 0 0 11
+2 0 0 0 0 1 0 0 45
+3 0 0 0 0 0 0 0 2
+4 0 1 0 0 0 0 0 5
+5 0 0 0 0 0 0 0 NA
+6 0 0 0 0 0 0 0 NA
+Source: MonetDB 11.19.0 (unreleased) []
+From: Batting [1,126 x 24]
+Filter: yearID > 2005, G > 130
-# 10:34:57 >
-# 10:34:57 > "Done."
-# 10:34:57 >
+ playerID yearID stint teamID lgID G G_batting AB R H X2B X3B HR RBI
+1 abreubo01 2007 1 NYA AL 158 158 605 123 171 40 5 16 101
+2 abreubo01 2008 1 NYA AL 156 156 609 100 180 39 4 20 100
+3 abreubo01 2009 1 LAA AL 152 152 563 96 165 29 3 15 103
+4 abreubo01 2010 1 LAA AL 154 154 573 88 146 41 1 20 78
+5 abreubo01 2011 1 LAA AL 142 142 502 54 127 30 1 8 60
+6 ackledu01 2012 1 SEA AL 153 NA 607 84 137 22 2 12 50
+7 alonsyo01 2012 1 SDN NL 155 NA 549 47 150 39 0 9 62
+8 altuvjo01 2012 1 HOU NL 147 NA 576 80 167 34 4 7 37
+9 alvarpe01 2012 1 PIT NL 149 NA 525 64 128 25 1 30 85
+10 amezaal01 2006 1 FLO NL 132 132 334 42 87 9 3 3 19
+.. ... ... ... ... ... ... ... ... ... ... ... ... .. ...
+Variables not shown: SB (dbl), CS (dbl), BB (dbl), SO (dbl), IBB (dbl), HBP
+ (dbl), SH (dbl), SF (dbl), GIDP (dbl), G_old (dbl)
+Source: MonetDB 11.19.0 (unreleased) []
+From: Batting [97,889 x 5]
+ playerID yearID stint teamID lgID
+1 aardsda01 2004 1 SFN NL
+2 aardsda01 2006 1 CHN NL
+3 aardsda01 2007 1 CHA AL
+4 aardsda01 2008 1 BOS AL
+5 aardsda01 2009 1 SEA AL
+6 aardsda01 2010 1 SEA AL
+7 aardsda01 2012 1 NYA AL
+8 aaronha01 1954 1 ML1 NL
+9 aaronha01 1955 1 ML1 NL
+10 aaronha01 1956 1 ML1 NL
+.. ... ... ... ... ...
+Source: MonetDB 11.19.0 (unreleased) []
+From: Batting [97,889 x 24]
+Arrange: playerID, desc(yearID)
+
+ playerID yearID stint teamID lgID G G_batting AB R H X2B X3B HR RBI
+1 aardsda01 2013 1 NYN NL 43 43 0 0 0 0 0 0 0
+2 aardsda01 2012 1 NYA AL 1 NA NA NA NA NA NA NA NA
+3 aardsda01 2010 1 SEA AL 53 4 0 0 0 0 0 0 0
+4 aardsda01 2009 1 SEA AL 73 3 0 0 0 0 0 0 0
+5 aardsda01 2008 1 BOS AL 47 5 1 0 0 0 0 0 0
+6 aardsda01 2007 1 CHA AL 25 2 0 0 0 0 0 0 0
+7 aardsda01 2006 1 CHN NL 45 43 2 0 0 0 0 0 0
+8 aardsda01 2004 1 SFN NL 11 11 0 0 0 0 0 0 0
+9 aaronha01 1976 1 ML4 AL 85 85 271 22 62 8 0 10 35
+10 aaronha01 1975 1 ML4 AL 137 137 465 45 109 16 2 12 60
+.. ... ... ... ... ... ... ... ... .. ... ... ... .. ...
+Variables not shown: SB (dbl), CS (dbl), BB (dbl), SO (dbl), IBB (dbl), HBP
+ (dbl), SH (dbl), SF (dbl), GIDP (dbl), G_old (dbl)
+Source: MonetDB 11.19.0 (unreleased) []
+From: <derived table> [?? x 2]
+
+ G n
+1 51.65408 97889
+.. ... ...
+Source: MonetDB 11.19.0 (unreleased) []
+From: Batting [97,889 x 25]
+
+ playerID yearID stint teamID lgID G G_batting AB R H X2B X3B HR RBI
+1 aardsda01 2004 1 SFN NL 11 11 0 0 0 0 0 0 0
+2 aardsda01 2006 1 CHN NL 45 43 2 0 0 0 0 0 0
+3 aardsda01 2007 1 CHA AL 25 2 0 0 0 0 0 0 0
+4 aardsda01 2008 1 BOS AL 47 5 1 0 0 0 0 0 0
+5 aardsda01 2009 1 SEA AL 73 3 0 0 0 0 0 0 0
+6 aardsda01 2010 1 SEA AL 53 4 0 0 0 0 0 0 0
+7 aardsda01 2012 1 NYA AL 1 NA NA NA NA NA NA NA NA
+8 aaronha01 1954 1 ML1 NL 122 122 468 58 131 27 6 13 69
+9 aaronha01 1955 1 ML1 NL 153 153 602 105 189 37 9 27 106
+10 aaronha01 1956 1 ML1 NL 153 153 609 106 200 34 14 26 92
+.. ... ... ... ... ... ... ... ... ... ... ... ... .. ...
+Variables not shown: SB (dbl), CS (dbl), BB (dbl), SO (dbl), IBB (dbl), HBP
+ (dbl), SH (dbl), SF (dbl), GIDP (dbl), G_old (dbl), rbi2 (dbl)
+#~BeginVariableOutput~#
+ user system elapsed
+ 0.009 0.000 0.010
+ user system elapsed
+ 0.024 0.001 0.082
+#~EndVariableOutput~#
+ [1] 8 23 7 13 3 4 2 10 6 5 1 3 12 5 11 10 4 1 12 8 1 3 1 5
+ [25] 3 17 2 3 3 7 10 1 1 19 1 1 5 3 3 9 5 5 10 12 4 3 2 4
+ [49] 3 3 6 6 4 15 1 6 19 8 1 2 15 1 8 2 1 1 1 8 3 1 1 3
+ [73] 2 2 3 5 10 1 1 3 5 1 14 4 12 5 2 17 2 5 4 7 1 6 3 1
+ [97] 2 2 1 6 1 6 4 13 6 13 2 4 7 15 11 4 19 16 1 1 8 3 17 5
+ [121] 3 1 1 5 14 4 1 1 4 1 1 1 4 3 9 2 2 1 3 4 3 3 4 1
+ [145] 2 13 12 2 4 9 4 2 6 23 8 3 1 9 12 2 21 6 1 11 13 6 13 8
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list