compute() stores results in a remote temporary table. collect() retrieves data into a local tibble. collapse() is slightly different: it doesn't force computation, but instead forces generation of the SQL query. This is sometimes needed to work around bugs in dplyr's SQL generation.

compute(x, name = random_table_name(), ...)

collect(x, ...)

collapse(x, ...)

Arguments

x

A tbl

name

Name of temporary table on database.

...

Other arguments passed on to methods

Details

All functions preserve grouping and ordering.

See also

copy_to(), the opposite of collect(): it takes a local data frame and uploads it to the remote source.

Examples

if (require(dbplyr)) { mtcars2 <- src_memdb() %>% copy_to(mtcars, name = "mtcars2-cc", overwrite = TRUE) remote <- mtcars2 %>% filter(cyl == 8) %>% select(mpg:drat) # Compute query and save in remote table compute(remote) # Compute query bring back to this session collect(remote) # Creates a fresh query based on the generated SQL collapse(remote) }
#> Loading required package: dbplyr
#> #> Attaching package: ‘dbplyr’
#> The following objects are masked from ‘package:dplyr’: #> #> ident, sql
#> # Source: SQL [?? x 5] #> # Database: sqlite 3.11.1 [:memory:] #> mpg cyl disp hp drat #> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 18.7 8 360.0 175 3.15 #> 2 14.3 8 360.0 245 3.21 #> 3 16.4 8 275.8 180 3.07 #> 4 17.3 8 275.8 180 3.07 #> 5 15.2 8 275.8 180 3.07 #> 6 10.4 8 472.0 205 2.93 #> 7 10.4 8 460.0 215 3.00 #> 8 14.7 8 440.0 230 3.23 #> 9 15.5 8 318.0 150 2.76 #> 10 15.2 8 304.0 150 3.15 #> # ... with more rows