Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_frugal() #530

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ S3method(add_count,duckplyr_df)
S3method(anti_join,duckplyr_df)
S3method(arrange,duckplyr_df)
S3method(as.data.frame,duckplyr_df)
S3method(as.data.frame,funneled_duckplyr_df)
S3method(as.data.frame,frugal_duckplyr_df)
S3method(as_duckdb_tibble,data.frame)
S3method(as_duckdb_tibble,default)
S3method(as_duckdb_tibble,duckplyr_df)
Expand All @@ -19,7 +19,7 @@ S3method(as_duckdb_tibble,tbl_duckdb_connection)
S3method(as_tibble,duckplyr_df)
S3method(auto_copy,duckplyr_df)
S3method(collect,duckplyr_df)
S3method(collect,funneled_duckplyr_df)
S3method(collect,frugal_duckplyr_df)
S3method(compute,duckplyr_df)
S3method(count,duckplyr_df)
S3method(cross_join,duckplyr_df)
Expand Down
2 changes: 1 addition & 1 deletion R/add_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_count.duckplyr_df <- function(x, ..., wt = NULL, sort = FALSE, name = NULL,
)

# dplyr forward
check_funneled(x, duckplyr_error)
check_prudence(x, duckplyr_error)

add_count <- dplyr$add_count.data.frame
out <- add_count(x, ..., wt = {{ wt }}, sort = sort, name = name, .drop = .drop)
Expand Down
2 changes: 1 addition & 1 deletion R/anti_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ anti_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches
)

# dplyr forward
check_funneled(x, duckplyr_error)
check_prudence(x, duckplyr_error)

anti_join <- dplyr$anti_join.data.frame
out <- anti_join(x, y, by, copy = FALSE, ..., na_matches = na_matches)
Expand Down
2 changes: 1 addition & 1 deletion R/arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ arrange.duckplyr_df <- function(.data, ..., .by_group = FALSE, .locale = NULL) {
)

# dplyr forward
check_funneled(.data, duckplyr_error)
check_prudence(.data, duckplyr_error)

arrange <- dplyr$arrange.data.frame
out <- arrange(.data, ..., .by_group = .by_group, .locale = .locale)
Expand Down
4 changes: 2 additions & 2 deletions R/compute-rd.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @title Compute results
#'
#' @description This is a method for the [dplyr::compute()] generic.
#' For a (funneled) duckplyr frame,
#' For a (frugal) duckplyr frame,
#' `compute()` executes a query but stores it in a (temporary) table,
#' or in a Parquet or CSV file.
#' The result is a duckplyr frame that can be used with subsequent dplyr verbs.
Expand All @@ -11,7 +11,7 @@
#' @param name The name of the table to store the result in.
#' @param schema_name The schema to store the result in, defaults to the current schema.
#' @param temporary Set to `FALSE` to store the result in a permanent table.
#' @inheritSection duckdb_tibble Funneling
#' @inheritSection duckdb_tibble Prudence
#' @examples
#' library(duckplyr)
#' df <- duckdb_tibble(x = c(1, 2))
Expand Down
12 changes: 6 additions & 6 deletions R/compute.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
compute.duckplyr_df <- function(
x,
...,
funnel = NULL,
collect = NULL,
name = NULL,
schema_name = NULL,
temporary = TRUE
) {
if (is.null(funnel)) {
funnel <- get_funnel_duckplyr_df(x)
if (is.null(collect)) {
collect <- get_collect_duckplyr_df(x)
}
if (is.null(schema_name)) {
schema_name <- ""
Expand All @@ -35,16 +35,16 @@ compute.duckplyr_df <- function(

out <- duckplyr_reconstruct(out_rel, x)

if (get_funnel_duckplyr_df(out) != funnel) {
out <- as_duckdb_tibble(out, funnel = funnel)
if (get_collect_duckplyr_df(out) != collect) {
out <- as_duckdb_tibble(out, collect = collect)
}

return(out)
}
)

# dplyr forward
check_funneled(x, duckplyr_error)
check_prudence(x, duckplyr_error)

compute <- dplyr$compute.data.frame
out <- compute(x, ...)
Expand Down
20 changes: 10 additions & 10 deletions R/compute_file.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' @title Compute results to a file
#'
#' @description
#' These functions apply to (funneled) duckplyr frames.
#' These functions apply to (frugal) duckplyr frames.
#' They executes a query and stores the results in a flat file.
#' The result is a duckplyr frame that can be used with subsequent dplyr verbs.
#'
#' `compute_parquet()` creates a Parquet file.
#'
#' @inheritParams rlang::args_dots_empty
#' @inheritParams compute.duckplyr_df
#' @inheritSection duckdb_tibble Funneling
#' @inheritSection duckdb_tibble Prudence
#' @param path The path to store the result in.
#' @param options A list of additional options to pass to create the storage format,
#' see <https://duckdb.org/docs/data/parquet/overview#writing-to-parquet-files>
Expand All @@ -26,15 +26,15 @@
#' explain(df)
#' @seealso [compute.duckplyr_df()], [dplyr::collect()]
#' @name compute_file
compute_parquet <- function(x, path, ..., funnel = NULL, options = NULL) {
compute_parquet <- function(x, path, ..., collect = NULL, options = NULL) {
check_dots_empty()

if (is.null(options)) {
options <- list()
}

if (is.null(funnel)) {
funnel <- get_funnel_duckplyr_df(x)
if (is.null(collect)) {
collect <- get_collect_duckplyr_df(x)
}

rel <- duckdb_rel_from_df(x)
Expand All @@ -46,23 +46,23 @@ compute_parquet <- function(x, path, ..., funnel = NULL, options = NULL) {
path <- file.path(path, "**", "**.parquet")
}

read_parquet_duckdb(path, funnel = funnel)
read_parquet_duckdb(path, collect = collect)
}

#' compute_csv()
#'
#' `compute_csv()` creates a CSV file.
#' @rdname compute_file
#' @export
compute_csv <- function(x, path, ..., funnel = NULL, options = NULL) {
compute_csv <- function(x, path, ..., collect = NULL, options = NULL) {
check_dots_empty()

if (is.null(options)) {
options <- list()
}

if (is.null(funnel)) {
funnel <- get_funnel_duckplyr_df(x)
if (is.null(collect)) {
collect <- get_collect_duckplyr_df(x)
}

rel <- duckdb_rel_from_df(x)
Expand All @@ -74,5 +74,5 @@ compute_csv <- function(x, path, ..., funnel = NULL, options = NULL) {
path <- file.path(path, "**", "**.csv")
}

read_csv_duckdb(path, funnel = funnel)
read_csv_duckdb(path, collect = collect)
}
2 changes: 1 addition & 1 deletion R/count.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ count.duckplyr_df <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .dro
# out <- count(x_df, !!!quos, wt = {{ wt }}, sort = sort, name = name, .drop = .drop)

# dplyr forward
check_funneled(x, duckplyr_error)
check_prudence(x, duckplyr_error)

count <- dplyr$count.data.frame
out <- count(x, ..., wt = {{ wt }}, sort = sort, name = name, .drop = .drop)
Expand Down
2 changes: 1 addition & 1 deletion R/cross_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cross_join.duckplyr_df <- function(x, y, ..., copy = FALSE, suffix = c(".x", ".y
)

# dplyr forward
check_funneled(x, duckplyr_error)
check_prudence(x, duckplyr_error)

cross_join <- dplyr$cross_join.data.frame
out <- cross_join(x, y, ..., copy = copy, suffix = suffix)
Expand Down
2 changes: 1 addition & 1 deletion R/distinct.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ distinct.duckplyr_df <- function(.data, ..., .keep_all = FALSE) {
)

# dplyr forward
check_funneled(.data, duckplyr_error)
check_prudence(.data, duckplyr_error)

distinct <- dplyr$distinct.data.frame
out <- distinct(.data, ..., .keep_all = .keep_all)
Expand Down
2 changes: 1 addition & 1 deletion R/do.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do.duckplyr_df <- function(.data, ...) {
)

# dplyr forward
check_funneled(.data, duckplyr_error)
check_prudence(.data, duckplyr_error)

do <- dplyr$do.data.frame
out <- do(.data, ...)
Expand Down
Loading
Loading