hannes / MonetDBLite

MonetDB reconfigured as a library
108 stars 11 forks source link

MonetDBLite and dplyr #182

Closed RCura closed 7 years ago

RCura commented 7 years ago

Hi, Trying to understand the issue #181 , I came to realise that it seems that a lot of MonetDBLite's dplyr.R code seems to be non working.

For example, there's a custom sample_n() function defined, but it gives this error message :

> # Create example dataset
> rep_data <- tibble(val = runif(n = 1E6), grp = if_else(val < .5, "A", "B"))
> # Copy this dataset to MonetDBLite
> con <- dbConnect(MonetDBLite::MonetDBLite(), "testData")
> dbWriteTable(conn = con, rep_data, name = "rep_data", overwrite = TRUE)
> 
> # Query this base
> thisTable <- tbl(src = con, "rep_data")
> thisTable %>% group_by(grp) %>% sample_n(size = 10) %>% show_query()
Error: `tbl` must be a data frame, not tbl_dbi/tbl_sql/tbl_lazy/tbl

I naively tried to add the tbl_monetdb class to this object (as dplyr.R code seems to rely on such object), but the problem remains :

> thisTable <- tbl(src = con, "rep_data")
> class(thisTable) <- c(class(thisTable), "tbl_monetdb")
> class(thisTable)
[1] "tbl_dbi"     "tbl_sql"     "tbl_lazy"    "tbl"         "tbl_monetdb"
> thisTable %>% group_by(grp) %>% sample_n(size = 10) %>% show_query()
Error: `tbl` must be a data frame, not tbl_dbi/tbl_sql/tbl_lazy/tbl/tbl_monetdb
hannes commented 7 years ago

Indeed sample_n is broken. My apologies. We had no test case for this, so it slipped through.

hannes commented 7 years ago

This should also be working again