Skip to content

Commit 03e57f5

Browse files
feat: Rename duck_tbl() to duckdb_tibble(), and as_duck_tbl() to as_duckdb_tibble() (#457)
* feat: Rename `*duck_tbl()` to `*duckdb_tibble()` * [create-pull-request] automated change (#458) Co-authored-by: krlmlr <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: krlmlr <[email protected]>
1 parent 6d432e1 commit 03e57f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+829
-827
lines changed

NAMESPACE

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ S3method(anti_join,duckplyr_df)
99
S3method(arrange,duckplyr_df)
1010
S3method(as.data.frame,duckplyr_df)
1111
S3method(as.data.frame,lazy_duckplyr_df)
12-
S3method(as_duck_tbl,data.frame)
13-
S3method(as_duck_tbl,default)
14-
S3method(as_duck_tbl,duckplyr_df)
15-
S3method(as_duck_tbl,grouped_df)
16-
S3method(as_duck_tbl,rowwise_df)
17-
S3method(as_duck_tbl,tbl_duckdb_connection)
12+
S3method(as_duckdb_tibble,data.frame)
13+
S3method(as_duckdb_tibble,default)
14+
S3method(as_duckdb_tibble,duckplyr_df)
15+
S3method(as_duckdb_tibble,grouped_df)
16+
S3method(as_duckdb_tibble,rowwise_df)
17+
S3method(as_duckdb_tibble,tbl_duckdb_connection)
1818
S3method(as_tibble,duckplyr_df)
1919
S3method(auto_copy,duckplyr_df)
2020
S3method(collect,duckplyr_df)
@@ -110,7 +110,7 @@ S3method(ungroup,duckplyr_df)
110110
S3method(union,duckplyr_df)
111111
S3method(union_all,duckplyr_df)
112112
export("%>%")
113-
export(as_duck_tbl)
113+
export(as_duckdb_tibble)
114114
export(as_duckplyr_df)
115115
export(as_duckplyr_tibble)
116116
export(compute_csv)
@@ -125,7 +125,7 @@ export(duck_file)
125125
export(duck_json)
126126
export(duck_parquet)
127127
export(duck_sql)
128-
export(duck_tbl)
128+
export(duckdb_tibble)
129129
export(duckplyr_df_from_csv)
130130
export(duckplyr_df_from_file)
131131
export(duckplyr_df_from_parquet)
@@ -136,7 +136,7 @@ export(fallback_review)
136136
export(fallback_sitrep)
137137
export(fallback_upload)
138138
export(flights_df)
139-
export(is_duck_tbl)
139+
export(is_duckdb_tibble)
140140
export(is_duckplyr_df)
141141
export(last_rel)
142142
export(methods_overwrite)

R/as_duckplyr_df.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
#' as_duckplyr_df() %>%
3232
#' mutate(b = a + 1)
3333
as_duckplyr_df <- function(.data) {
34-
lifecycle::deprecate_soft("1.0.0", "as_duckplyr_df()", "as_duck_tbl()")
34+
lifecycle::deprecate_soft("1.0.0", "as_duckplyr_df()", "as_duckdb_tibble()")
3535

3636
as_duckplyr_df_impl(.data)
3737
}
3838

3939
as_duckplyr_df_impl <- function(x, error_call = caller_env()) {
40-
# FIXME: Move to as_duck_tbl()
40+
# FIXME: Move to as_duckdb_tibble()
4141
if (!identical(class(x), "data.frame") && !identical(class(x), c("tbl_df", "tbl", "data.frame"))) {
4242
cli::cli_abort(call = error_call, c(
4343
"Must pass a plain data frame or a tibble, not {.obj_type_friendly {x}}.",
4444
i = "Convert it with {.fun as.data.frame} or {.fun tibble::as_tibble}."
4545
))
4646
}
4747

48-
new_duck_tbl(x, class = class(x), error_call = error_call)
48+
new_duckdb_tibble(x, class = class(x), error_call = error_call)
4949
}

R/as_duckplyr_tibble.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' @rdname as_duckplyr_df
99
#' @export
1010
as_duckplyr_tibble <- function(.data) {
11-
lifecycle::deprecate_soft("1.0.0", "as_duckplyr_tibble()", "as_duck_tbl()")
11+
lifecycle::deprecate_soft("1.0.0", "as_duckplyr_tibble()", "as_duckdb_tibble()")
1212

1313
if (inherits(.data, "tbl_duckdb_connection")) {
1414
con <- dbplyr::remote_con(.data)

R/collect-rd.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @inheritParams dplyr::collect
77
#' @examples
88
#' library("duckplyr")
9-
#' df <- duck_tbl(x = c(1, 2), .lazy = TRUE)
9+
#' df <- duckdb_tibble(x = c(1, 2), .lazy = TRUE)
1010
#' df
1111
#' try(print(df$x))
1212
#' df <- collect(df)

R/compute-rd.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#'
99
#' @inheritParams dplyr::compute
1010
#' @param lazy Set to `TRUE` to return a lazy or `FALSE` to return an eager data frame,
11-
#' see the "Eager and lazy" section in [duck_tbl()].
11+
#' see the "Eager and lazy" section in [duckdb_tibble()].
1212
#' The default is to inherit the lazyness of the input.
1313
#' @param name The name of the table to store the result in.
1414
#' @param schema_name The schema to store the result in, defaults to the current schema.
1515
#' @param temporary Set to `FALSE` to store the result in a permanent table.
1616
#' @examples
1717
#' library("duckplyr")
18-
#' df <- duck_tbl(x = c(1, 2))
18+
#' df <- duckdb_tibble(x = c(1, 2))
1919
#' df <- mutate(df, y = 2)
2020
#' df <- compute(df)
2121
#' explain(df)

R/compute.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ compute.duckplyr_df <- function(
3737
out <- duckplyr_reconstruct(out_rel, x)
3838

3939
if (is_lazy_duckplyr_df(out) != lazy) {
40-
out <- as_duck_tbl(out, .lazy = lazy)
40+
out <- as_duckdb_tibble(out, .lazy = lazy)
4141
}
4242

4343
return(out)

R/ducktbl.R

+33-33
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' For such objects,
88
#' dplyr verbs such as [mutate()], [select()] or [filter()] will use DuckDB.
99
#'
10-
#' `duck_tbl()` works like [tibble()], returning an "eager" duckplyr data frame by default.
10+
#' `duckdb_tibble()` works like [tibble()], returning an "eager" duckplyr data frame by default.
1111
#' See the "Eager and lazy" section below.
1212
#'
1313
#' @section Eager and lazy:
@@ -24,7 +24,7 @@
2424
#' Once the results are computed, they are cached and subsequent requests are fast.
2525
#' This is a good choice for small to medium-sized data,
2626
#' where DuckDB can provide a nice speedup but materializing the data is affordable.
27-
#' This is the default for `duck_tbl()` and `as_duck_tbl()`.
27+
#' This is the default for `duckdb_tibble()` and `as_duckdb_tibble()`.
2828
#' Use `.lazy = TRUE` for these functions to check
2929
#' that all operations are supported by DuckDB.
3030
#'
@@ -37,7 +37,7 @@
3737
#' It is safe to use `duck_parquet(lazy = FALSE)`
3838
#' if the data is small enough to be materialized at any stage.
3939
#'
40-
#' A lazy duckplyr frame can be converted to an eager one with `as_duck_tbl(.lazy = FALSE)`.
40+
#' A lazy duckplyr frame can be converted to an eager one with `as_duckdb_tibble(.lazy = FALSE)`.
4141
#' The [collect.duckplyr_df()] method converts to a plain tibble.
4242
#' Other useful methods include [compute_file()] for storing results in a file,
4343
#' and [compute.duckplyr_df()] for storing results in temporary storage on disk.
@@ -54,18 +54,18 @@
5454
#' but "eager" tables are not available there at the time of writing,
5555
#' and the data must always be brought into R memory through [collect()].
5656
#'
57-
#' @param ... For `duck_tbl()`, passed on to [tibble()].
58-
#' For `as_duck_tbl()`, passed on to methods.
57+
#' @param ... For `duckdb_tibble()`, passed on to [tibble()].
58+
#' For `as_duckdb_tibble()`, passed on to methods.
5959
#' @param .lazy Logical, whether to create a lazy duckplyr frame.
6060
#' See the section "Eager and lazy" for details.
6161
#'
62-
#' @return For `duck_tbl()` and `as_duck_tbl()`, an object with the following classes:
62+
#' @return For `duckdb_tibble()` and `as_duckdb_tibble()`, an object with the following classes:
6363
#' - `"lazy_duckplyr_df"` if `.lazy` is `TRUE`
6464
#' - `"duckplyr_df"`
6565
#' - Classes of a [tibble]
6666
#'
6767
#' @examples
68-
#' x <- duck_tbl(a = 1)
68+
#' x <- duckdb_tibble(a = 1)
6969
#' x
7070
#'
7171
#' library(dplyr)
@@ -74,26 +74,26 @@
7474
#'
7575
#' x$a
7676
#'
77-
#' y <- duck_tbl(a = 1, .lazy = TRUE)
77+
#' y <- duckdb_tibble(a = 1, .lazy = TRUE)
7878
#' y
7979
#' try(length(y$a))
8080
#' length(collect(y)$a)
8181
#' @export
82-
duck_tbl <- function(..., .lazy = FALSE) {
82+
duckdb_tibble <- function(..., .lazy = FALSE) {
8383
out <- tibble::tibble(...)
84-
as_duck_tbl(out, .lazy = .lazy)
84+
as_duckdb_tibble(out, .lazy = .lazy)
8585
}
8686

87-
#' as_duck_tbl
87+
#' as_duckdb_tibble
8888
#'
89-
#' `as_duck_tbl()` converts a data frame or a dplyr lazy table to a duckplyr data frame.
89+
#' `as_duckdb_tibble()` converts a data frame or a dplyr lazy table to a duckplyr data frame.
9090
#' This is a generic function that can be overridden for custom classes.
9191
#'
9292
#' @param x The object to convert or to test.
93-
#' @rdname duck_tbl
93+
#' @rdname duckdb_tibble
9494
#' @export
95-
as_duck_tbl <- function(x, ..., .lazy = FALSE) {
96-
out <- as_duck_tbl_dispatch(x, ...)
95+
as_duckdb_tibble <- function(x, ..., .lazy = FALSE) {
96+
out <- as_duckdb_tibble_dispatch(x, ...)
9797

9898
if (isTRUE(.lazy)) {
9999
out <- as_lazy_duckplyr_df(out)
@@ -102,14 +102,14 @@ as_duck_tbl <- function(x, ..., .lazy = FALSE) {
102102
}
103103

104104
return(out)
105-
UseMethod("as_duck_tbl")
105+
UseMethod("as_duckdb_tibble")
106106
}
107-
as_duck_tbl_dispatch <- function(x, ...) {
108-
UseMethod("as_duck_tbl")
107+
as_duckdb_tibble_dispatch <- function(x, ...) {
108+
UseMethod("as_duckdb_tibble")
109109
}
110110

111111
#' @export
112-
as_duck_tbl.tbl_duckdb_connection <- function(x, ...) {
112+
as_duckdb_tibble.tbl_duckdb_connection <- function(x, ...) {
113113
check_dots_empty()
114114

115115
con <- dbplyr::remote_con(x)
@@ -119,33 +119,33 @@ as_duck_tbl.tbl_duckdb_connection <- function(x, ...) {
119119
}
120120

121121
#' @export
122-
as_duck_tbl.duckplyr_df <- function(x, ...) {
122+
as_duckdb_tibble.duckplyr_df <- function(x, ...) {
123123
check_dots_empty()
124124
x
125125
}
126126

127127
#' @export
128-
as_duck_tbl.data.frame <- function(x, ...) {
128+
as_duckdb_tibble.data.frame <- function(x, ...) {
129129
check_dots_empty()
130130

131131
tbl <- as_tibble(x)
132132

133133
# - as_tibble() to remove row names
134-
new_duck_tbl(tbl)
134+
new_duckdb_tibble(tbl)
135135
}
136136

137137
#' @export
138-
as_duck_tbl.default <- function(x, ...) {
138+
as_duckdb_tibble.default <- function(x, ...) {
139139
check_dots_empty()
140140

141141
# - as.data.frame() call for good measure and perhaps https://github.com/tidyverse/tibble/issues/1556
142142
# - as_tibble() to remove row names
143-
# Could call as_duck_tbl(as.data.frame(x)) here, but that would be slower
144-
new_duck_tbl(as_tibble(as.data.frame(x)))
143+
# Could call as_duckdb_tibble(as.data.frame(x)) here, but that would be slower
144+
new_duckdb_tibble(as_tibble(as.data.frame(x)))
145145
}
146146

147147
#' @export
148-
as_duck_tbl.grouped_df <- function(x, ...) {
148+
as_duckdb_tibble.grouped_df <- function(x, ...) {
149149
check_dots_empty()
150150

151151
cli::cli_abort(c(
@@ -156,7 +156,7 @@ as_duck_tbl.grouped_df <- function(x, ...) {
156156
}
157157

158158
#' @export
159-
as_duck_tbl.rowwise_df <- function(x, ...) {
159+
as_duckdb_tibble.rowwise_df <- function(x, ...) {
160160
check_dots_empty()
161161

162162
cli::cli_abort(c(
@@ -165,21 +165,21 @@ as_duck_tbl.rowwise_df <- function(x, ...) {
165165
))
166166
}
167167

168-
#' is_duck_tbl
168+
#' is_duckdb_tibble
169169
#'
170-
#' `is_duck_tbl()` returns `TRUE` if `x` is a duckplyr data frame.
170+
#' `is_duckdb_tibble()` returns `TRUE` if `x` is a duckplyr data frame.
171171
#'
172-
#' @return For `is_duck_tbl()`, a scalar logical.
173-
#' @rdname duck_tbl
172+
#' @return For `is_duckdb_tibble()`, a scalar logical.
173+
#' @rdname duckdb_tibble
174174
#' @export
175-
is_duck_tbl <- function(x) {
175+
is_duckdb_tibble <- function(x) {
176176
inherits(x, "duckplyr_df")
177177
}
178178

179179

180180
#' @param lazy Only adds the class, does not recreate the relation object!
181181
#' @noRd
182-
new_duck_tbl <- function(x, class = NULL, lazy = FALSE, error_call = caller_env()) {
182+
new_duckdb_tibble <- function(x, class = NULL, lazy = FALSE, error_call = caller_env()) {
183183
if (is.null(class)) {
184184
class <- c("tbl_df", "tbl", "data.frame")
185185
}

R/flights.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' Provides a copy of `nycflights13::flights` that is compatible with duckplyr,
44
#' as a tibble.
5-
#' Call [as_duck_tbl()] to enable duckplyr operations.
5+
#' Call [as_duckdb_tibble()] to enable duckplyr operations.
66
#'
77
#' @export
88
#' @examplesIf requireNamespace("nycflights13", quietly = TRUE)

R/io2.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ duck_json <- function(path, ..., lazy = TRUE, options = list()) {
100100
#' `"read_csv"`, `"read_csv_auto"` or `"read_json"`.
101101
#' @param lazy Logical, whether to create a lazy duckplyr frame.
102102
#' By default, a lazy duckplyr frame is created.
103-
#' See the "Eager and lazy" section in [duck_tbl()] for details.
103+
#' See the "Eager and lazy" section in [duckdb_tibble()] for details.
104104
#' @param options Arguments to the DuckDB function
105105
#' indicated by `table_function`.
106106
#'
107-
#' @return A duckplyr frame, see [as_duck_tbl()] for details.
107+
#' @return A duckplyr frame, see [as_duckdb_tibble()] for details.
108108
#'
109109
#' @rdname duck_file
110110
#' @export
@@ -154,10 +154,10 @@ duckfun <- function(table_function, args, ..., lazy = TRUE) {
154154

155155
# Start with lazy, to avoid unwanted materialization
156156
df <- duckdb$rel_to_altrep(rel, allow_materialization = FALSE)
157-
out <- new_duck_tbl(df, lazy = TRUE)
157+
out <- new_duckdb_tibble(df, lazy = TRUE)
158158

159159
if (!lazy) {
160-
out <- as_duck_tbl(out, .lazy = lazy)
160+
out <- as_duckdb_tibble(out, .lazy = lazy)
161161
}
162162

163163
out

R/is_duckplyr_df.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' as_duckplyr_df() %>%
2121
#' is_duckplyr_df()
2222
is_duckplyr_df <- function(.data) {
23-
lifecycle::deprecate_soft("1.0.0", "is_duckplyr_df()", "is_duck_tbl()")
23+
lifecycle::deprecate_soft("1.0.0", "is_duckplyr_df()", "is_duckdb_tibble()")
2424

2525
inherits(.data, "duckplyr_df")
2626
}

R/relational-duckdb.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ duckdb_rel_from_df <- function(df) {
9595
return(rel)
9696
}
9797

98-
if (!is_duck_tbl(df)) {
98+
if (!is_duckdb_tibble(df)) {
9999
df <- as_duckplyr_df_impl(df)
100100
}
101101

R/relational.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ check_lazy <- function(x, duckplyr_error, call = caller_env()) {
132132
"This operation cannot be carried out by DuckDB, and the input is a lazy duckplyr frame.",
133133
"*" = duckplyr_error_msg,
134134
"*" = "Use {.code compute(lazy = FALSE)} to materialize to temporary storage and continue with {.pkg duckplyr}.",
135-
"*" = 'See the "Eager and lazy" section in {.help duck_tbl} for other options.'
135+
"*" = 'See the "Eager and lazy" section in {.help duckdb_tibble} for other options.'
136136
))
137137
}
138138
}

R/sql.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Return SQL query as duck_tbl
1+
#' Return SQL query as duckdb_tibble
22
#'
33
#' @description
44
#' `r lifecycle::badge("experimental")`
@@ -33,5 +33,5 @@ duck_sql <- function(sql, ..., lazy = TRUE, con = NULL) {
3333
meta_rel_register(rel, expr(duckdb$rel_from_sql(con, !!sql)))
3434

3535
out <- duckdb$rel_to_altrep(rel)
36-
as_duck_tbl(out, .lazy = lazy)
36+
as_duckdb_tibble(out, .lazy = lazy)
3737
}

README.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Fallback is silent by default, but can be made verbose.
248248
Sys.setenv(DUCKPLYR_FALLBACK_INFO = TRUE)
249249
out <-
250250
nycflights13::flights %>%
251-
duckplyr::as_duck_tbl() %>%
251+
duckplyr::as_duckdb_tibble() %>%
252252
mutate(inflight_delay = arr_delay - dep_delay)
253253
```
254254

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Fallback is silent by default, but can be made verbose.
367367
Sys.setenv(DUCKPLYR_FALLBACK_INFO = TRUE)
368368
out <-
369369
nycflights13::flights %>%
370-
duckplyr::as_duck_tbl() %>%
370+
duckplyr::as_duckdb_tibble() %>%
371371
mutate(inflight_delay = arr_delay - dep_delay)
372372
#> Error processing duckplyr query with DuckDB, falling back to dplyr.
373373
#> Caused by error in `check_df_for_rel()` at duckplyr/R/relational-duckdb.R:100:3:

_pkgdown.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ template:
1111
reference:
1212
- title: Using duckplyr
1313
contents:
14-
- duck_tbl
14+
- duckdb_tibble
1515
- duck_file
1616
- duck_sql
1717

0 commit comments

Comments
 (0)