compute: Force computation of a database query

Description Usage Arguments Details See Also Examples

Description

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.

Usage

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)
}

olascodgreat/samife documentation built on May 13, 2019, 6:11 p.m.