forked from tidyverse/dplyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute.Rd
69 lines (57 loc) · 2 KB
/
compute.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compute-collect.r
\name{compute}
\alias{compute}
\alias{collect}
\alias{collapse}
\title{Force computation of a database query}
\usage{
compute(x, name = random_table_name(), ...)
collect(x, ...)
collapse(x, ...)
}
\arguments{
\item{x}{A data frame, data frame extension (e.g. a tibble), or a lazy
data frame (e.g. from dbplyr or dtplyr). See \emph{Methods}, below, for more
details.}
\item{name}{Name of temporary table on database.}
\item{...}{Other arguments passed on to methods}
}
\description{
\code{compute()} stores results in a remote temporary table.
\code{collect()} retrieves data into a local tibble.
\code{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.
All functions preserve grouping and ordering.
}
\section{Methods}{
These functions are \strong{generics}, which means that packages can provide
implementations (methods) for other classes. See the documentation of
individual methods for extra arguments and differences in behaviour.
Methods available in currently loaded packages:
\itemize{
\item \code{compute()}: \Sexpr[stage=render,results=rd]{dplyr:::methods_rd("compute")}
\item \code{collect()}: \Sexpr[stage=render,results=rd]{dplyr:::methods_rd("collect")}
\item \code{collapse()}: \Sexpr[stage=render,results=rd]{dplyr:::methods_rd("collapse")}
}
}
\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)
}
}
\seealso{
\code{\link[=copy_to]{copy_to()}}, the opposite of \code{collect()}: it takes a local data
frame and uploads it to the remote source.
}