Skip to content

Commit 097102f

Browse files
authored
docs: Use stingy instead of frugal (#594)
* docs: Use stingy instead of frugal * Catch * Define
1 parent 3092054 commit 097102f

22 files changed

+124
-115
lines changed

R/compute-rd.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' intermediate results in DuckDB-managed memory to data frames in R memory.
1717
#'
1818
#' - `"lavish"`: regardless of size,
19-
#' - `"frugal"`: never,
19+
#' - `"stingy"`: never,
2020
#' - `"thrifty"`: up to a maximum size of 1 million cells.
2121
#'
2222
#' The default is to inherit from the input.

R/duckplyr_df.R

+13-4
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,22 @@ prudence_parse <- function(prudence, call = caller_env()) {
7474
}
7575
}
7676
allow_materialization <- is.finite(n_rows) || is.finite(n_cells)
77-
prudence <- "frugal"
77+
prudence <- "stingy"
7878
} else if (!is.character(prudence)) {
7979
cli::cli_abort("{.arg prudence} must be an unnamed character vector or a named numeric vector", call = call)
8080
} else {
81-
prudence <- arg_match(prudence, c("lavish", "frugal", "thrifty"), error_call = call)
81+
if (identical(prudence, "frugal")) {
82+
lifecycle::deprecate_warn("1.0.0",
83+
I('Use `prudence = "stingy"` instead, `prudence = "frugal"`'),
84+
always = TRUE,
85+
env = call
86+
)
87+
prudence <- "stingy"
88+
}
89+
# Can't change second argument to arg_match() here
90+
prudence <- arg_match(prudence, c("lavish", "stingy", "thrifty"), error_call = call)
8291

83-
allow_materialization <- !identical(prudence, "frugal")
92+
allow_materialization <- !identical(prudence, "stingy")
8493
if (!allow_materialization) {
8594
n_cells <- 0
8695
} else if (identical(prudence, "thrifty")) {
@@ -104,7 +113,7 @@ get_prudence_duckplyr_df <- function(x) {
104113

105114
prudence <- attr(x, "prudence")
106115
if (is.null(prudence)) {
107-
return("frugal")
116+
return("stingy")
108117
}
109118

110119
if (identical(prudence, c(cells = 1e6))) {

R/ducktbl.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' intermediate results in DuckDB-managed memory to data frames in R memory.
1616
#'
1717
#' - `"lavish"`: regardless of size,
18-
#' - `"frugal"`: never,
18+
#' - `"stingy"`: never,
1919
#' - `"thrifty"`: up to a maximum size of 1 million cells.
2020
#'
2121
#' The default is `"lavish"` for `duckdb_tibble()` and `as_duckdb_tibble()`,
@@ -47,12 +47,12 @@
4747
#'
4848
#' x$a
4949
#'
50-
#' y <- duckdb_tibble(a = 1, .prudence = "frugal")
50+
#' y <- duckdb_tibble(a = 1, .prudence = "stingy")
5151
#' y
5252
#' try(length(y$a))
5353
#' length(collect(y)$a)
5454
#' @export
55-
duckdb_tibble <- function(..., .prudence = c("lavish", "thrifty", "frugal")) {
55+
duckdb_tibble <- function(..., .prudence = c("lavish", "thrifty", "stingy")) {
5656
out <- tibble::tibble(...)
5757

5858
# Side effect: check compatibility
@@ -72,7 +72,7 @@ duckdb_tibble <- function(..., .prudence = c("lavish", "thrifty", "frugal")) {
7272
#' @param x The object to convert or to test.
7373
#' @rdname duckdb_tibble
7474
#' @export
75-
as_duckdb_tibble <- function(x, ..., prudence = c("lavish", "thrifty", "frugal")) {
75+
as_duckdb_tibble <- function(x, ..., prudence = c("lavish", "thrifty", "stingy")) {
7676
# Handle the prudence arg in the generic, only the other args will be dispatched
7777
as_duckdb_tibble <- function(x, ...) {
7878
UseMethod("as_duckdb_tibble")
@@ -90,7 +90,7 @@ as_duckdb_tibble.tbl_duckdb_connection <- function(x, ...) {
9090
sql <- dbplyr::remote_query(x)
9191

9292
# Start restrictive to avoid accidental materialization
93-
read_sql_duckdb(sql, prudence = "frugal", con = con)
93+
read_sql_duckdb(sql, prudence = "stingy", con = con)
9494
}
9595

9696
#' @export

R/io2.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ NULL
1313
#'
1414
#' @rdname read_file_duckdb
1515
#' @export
16-
read_parquet_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "frugal"), options = list()) {
16+
read_parquet_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "stingy"), options = list()) {
1717
check_dots_empty()
1818

1919
read_file_duckdb(path, "read_parquet", prudence = prudence, options = options)
@@ -50,7 +50,7 @@ read_parquet_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "fr
5050
#' path,
5151
#' options = list(delim = ",", types = list(c("DOUBLE", "VARCHAR")))
5252
#' )
53-
read_csv_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "frugal"), options = list()) {
53+
read_csv_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "stingy"), options = list()) {
5454
check_dots_empty()
5555

5656
read_file_duckdb(path, "read_csv_auto", prudence = prudence, options = options)
@@ -71,7 +71,7 @@ read_csv_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "frugal
7171
#' db_exec("INSTALL json")
7272
#' db_exec("LOAD json")
7373
#' read_json_duckdb(path)
74-
read_json_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "frugal"), options = list()) {
74+
read_json_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "stingy"), options = list()) {
7575
check_dots_empty()
7676

7777
read_file_duckdb(path, "read_json", prudence = prudence, options = options)
@@ -95,7 +95,7 @@ read_json_duckdb <- function(path, ..., prudence = c("thrifty", "lavish", "fruga
9595
#'
9696
#' - `"thrifty"`: up to a maximum size of 1 million cells,
9797
#' - `"lavish"`: regardless of size,
98-
#' - `"frugal"`: never.
98+
#' - `"stingy"`: never.
9999
#'
100100
#' The default is `"thrifty"` for the ingestion functions,
101101
#' and may be different for other functions.
@@ -114,7 +114,7 @@ read_file_duckdb <- function(
114114
path,
115115
table_function,
116116
...,
117-
prudence = c("thrifty", "lavish", "frugal"),
117+
prudence = c("thrifty", "lavish", "stingy"),
118118
options = list()
119119
) {
120120
check_dots_empty()

R/mutate.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mutate.duckplyr_df <- function(.data, ..., .by = NULL, .keep = c("all", "used",
2323

2424
names_used <- character()
2525
names_new <- character()
26-
current_data <- rel_to_df(rel, prudence = "frugal")
26+
current_data <- rel_to_df(rel, prudence = "stingy")
2727

2828
# FIXME: use fewer projections
2929
for (i in seq_along(dots)) {
@@ -71,7 +71,7 @@ mutate.duckplyr_df <- function(.data, ..., .by = NULL, .keep = c("all", "used",
7171
}
7272

7373
rel <- rel_project(rel, unname(exprs))
74-
current_data <- rel_to_df(rel, prudence = "frugal")
74+
current_data <- rel_to_df(rel, prudence = "stingy")
7575
}
7676

7777
if (length(by_names) > 0) {

R/relational.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ check_prudence <- function(x, duckplyr_error, call = caller_env()) {
141141
duckplyr_error_msg <- if (is.character(duckplyr_error)) duckplyr_error
142142
duckplyr_error_parent <- if (is_condition(duckplyr_error)) duckplyr_error
143143
cli::cli_abort(parent = duckplyr_error_parent, call = call, c(
144-
"This operation cannot be carried out by DuckDB, and the input is a frugal duckplyr frame.",
144+
"This operation cannot be carried out by DuckDB, and the input is a stingy duckplyr frame.",
145145
"*" = duckplyr_error_msg,
146146
"i" = 'Use {.code compute(prudence = "lavish")} to materialize to temporary storage and continue with {.pkg duckplyr}.',
147147
"i" = 'See {.run vignette("prudence")} for other options.'

R/sql.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' @export
1919
#' @examples
2020
#' read_sql_duckdb("FROM duckdb_settings()")
21-
read_sql_duckdb <- function(sql, ..., prudence = c("thrifty", "lavish", "frugal"), con = NULL) {
21+
read_sql_duckdb <- function(sql, ..., prudence = c("thrifty", "lavish", "stingy"), con = NULL) {
2222
if (!is_string(sql)) {
2323
cli::cli_abort("{.arg sql} must be a string.")
2424
}

man/compute.duckplyr_df.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/compute_file.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/duckdb_tibble.Rd

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/read_file_duckdb.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/read_sql_duckdb.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

patch/mutate.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ diff --git b/R/mutate.R a/R/mutate.R
2929
+
3030
+ names_used <- character()
3131
+ names_new <- character()
32-
+ current_data <- rel_to_df(rel, prudence = "frugal")
32+
+ current_data <- rel_to_df(rel, prudence = "stingy")
3333
+
3434
+ # FIXME: use fewer projections
3535
+ for (i in seq_along(dots)) {
@@ -77,7 +77,7 @@ diff --git b/R/mutate.R a/R/mutate.R
7777
+ }
7878
+
7979
+ rel <- rel_project(rel, unname(exprs))
80-
+ current_data <- rel_to_df(rel, prudence = "frugal")
80+
+ current_data <- rel_to_df(rel, prudence = "stingy")
8181
+ }
8282
+
8383
+ if (length(by_names) > 0) {

tests/testthat/_snaps/handle_desc.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# desc() fails if it points elsewhere
22

33
Code
4-
duckdb_tibble(a = 1:3, .prudence = "frugal") %>% arrange(desc(a))
4+
duckdb_tibble(a = 1:3, .prudence = "stingy") %>% arrange(desc(a))
55
Condition
66
Error in `arrange()`:
7-
! This operation cannot be carried out by DuckDB, and the input is a frugal duckplyr frame.
7+
! This operation cannot be carried out by DuckDB, and the input is a stingy duckplyr frame.
88
i Use `compute(prudence = "lavish")` to materialize to temporary storage and continue with duckplyr.
99
i See `vignette("prudence")` for other options.
1010
Caused by error in `arrange()`:
@@ -13,10 +13,10 @@
1313
# desc() fails for more than one argument
1414

1515
Code
16-
duckdb_tibble(a = 1:3, b = 4:6, .prudence = "frugal") %>% arrange(desc(a, b))
16+
duckdb_tibble(a = 1:3, b = 4:6, .prudence = "stingy") %>% arrange(desc(a, b))
1717
Condition
1818
Error in `arrange()`:
19-
! This operation cannot be carried out by DuckDB, and the input is a frugal duckplyr frame.
19+
! This operation cannot be carried out by DuckDB, and the input is a stingy duckplyr frame.
2020
i Use `compute(prudence = "lavish")` to materialize to temporary storage and continue with duckplyr.
2121
i See `vignette("prudence")` for other options.
2222
Caused by error in `arrange()`:

tests/testthat/test-compute_file.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test_that("compute_csv()", {
2929
test_that("compute_csv() prudence", {
3030
df <- data.frame(x = c(1, 2))
3131
withr::defer(unlink("test.csv"))
32-
out <- compute_csv(df, path = "test.csv", prudence = "frugal")
32+
out <- compute_csv(df, path = "test.csv", prudence = "stingy")
3333

3434
expect_true(is_prudent_duckplyr_df(out))
3535
expect_identical(collect(out), as_tibble(df))

tests/testthat/test-ducktbl.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ test_that("Can construct", {
77
expect_identical(duckdb_tibble(a = 1)$a, 1)
88
})
99

10-
test_that('.prudence = "frugal" forbids materialization', {
11-
tbl <- duckdb_tibble(a = 1, .prudence = "frugal")
10+
test_that('.prudence = "stingy" forbids materialization', {
11+
tbl <- duckdb_tibble(a = 1, .prudence = "stingy")
1212
expect_error(length(tbl$a))
1313
})
1414

@@ -22,8 +22,8 @@ test_that('.prudence = c(cells = ) forbids materialization', {
2222
expect_error(length(tbl$a))
2323
})
2424

25-
test_that('.prudence = "frugal" forbids materialization for as_duckdb_tibble', {
26-
tbl <- as_duckdb_tibble(data.frame(a = 1), prudence = "frugal")
25+
test_that('.prudence = "stingy" forbids materialization for as_duckdb_tibble', {
26+
tbl <- as_duckdb_tibble(data.frame(a = 1), prudence = "stingy")
2727
expect_error(length(tbl$a))
2828
})
2929

@@ -64,14 +64,14 @@ test_that("as_duckdb_tibble() and dbplyr tables", {
6464
dplyr::copy_to(dest = con)
6565

6666
duck <- db_tbl %>%
67-
as_duckdb_tibble(prudence = "frugal") %>%
67+
as_duckdb_tibble(prudence = "stingy") %>%
6868
mutate(b = 2)
6969

7070
expect_error(length(duck$b))
7171

7272
db <- db_tbl %>%
7373
mutate(b = 2) %>%
74-
as_duckdb_tibble(prudence = "frugal")
74+
as_duckdb_tibble(prudence = "stingy")
7575

7676
expect_error(length(db$b))
7777

0 commit comments

Comments
 (0)