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

chore: R CMD check fixes #42

Merged
merged 14 commits into from
Sep 6, 2023
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
^res-duckdb\.csv$
^\.github$
^R/qs\.R$
^\.sync$
^res-duckplyr-raw\.csv$
^res-duckplyr\.csv$
^res-relational-duckdb\.csv$
^R/meta\.R$
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'
error-on: '"warning"'
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ Suggests:
lobstr,
lubridate,
palmerpenguins,
pillar,
prettycode,
qs,
styler,
testthat (>= 3.1.5),
withr
Encoding: UTF-8
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ S3method(distinct,duckplyr_df)
S3method(do,duckplyr_df)
S3method(dplyr_reconstruct,duckplyr_df)
S3method(explain,duckplyr_df)
S3method(filter,duckplyr_df)
S3method(format,relational_relexpr)
S3method(full_join,duckplyr_df)
S3method(group_vars,duckplyr_df)
Expand Down
6 changes: 6 additions & 0 deletions R/aaa-meta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Overwritten in meta.R
meta_rel_register <- function(...) {}
meta_rel_register_df <- function(...) {}
meta_rel_register_file <- function(...) {}
meta_rel_get <- function(...) {}
meta_macro_register <- function(...) {}
4 changes: 4 additions & 0 deletions R/as_duckplyr_df.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#' Convert to a duckplyr data frame
#'
#' @param .data data frame or tibble to transform
#'
#' @export
as_duckplyr_df <- function(.data) {
if (inherits(.data, "duckplyr_df")) {
Expand Down
14 changes: 14 additions & 0 deletions R/csv.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#' TODO
#'
#' @param path Path to file TODO add what kind
#'
#' @param table_function TODO
#' @param options TODO
#'
#' @export
duckdb_from_file <- function(path, table_function, options=list()) {
# FIXME: For some reason, it's important to create an alias here
Expand All @@ -15,6 +22,13 @@ duckdb_from_file <- function(path, table_function, options=list()) {
duckdb:::rel_to_altrep(out)
}

#' TODO
#'
#' @param path Path to file TODO add what kind
#'
#' @param table_function TODO
#' @param options TODO
#'
#' @export
duckplyr_df_from_file <- function(path, table_function, options=list()) {
out <- duckdb_from_file(path, table_function, options)
Expand Down
7 changes: 6 additions & 1 deletion R/filter.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Generated by 02-duckplyr_df-methods.R
#' @export

# Needed for R <= 4.2, can't use @export here:
on_load({
vctrs::s3_register("dplyr::filter", "duckplyr_df")
})

filter.duckplyr_df <- function(.data, ..., .by = NULL, .preserve = FALSE) {
force(.data)

Expand Down
4 changes: 4 additions & 0 deletions R/is_duckplyr_df.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#' Class predicate for duckplyr data frames
#'
#' @param .data Data
#'
#' @export
is_duckplyr_df <- function(.data) {
inherits(.data, "duckplyr_df")
Expand Down
2 changes: 2 additions & 0 deletions R/overwrite.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' Methods overwriting
#'
#' @export
methods_overwrite <- function() {
vctrs::s3_register("dplyr::add_count", "data.frame", duckplyr:::add_count.duckplyr_df)
Expand Down
8 changes: 8 additions & 0 deletions R/relational-altrep-wrap.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#' TODO
#'
#' @param x TODO row
#'
#' @export
wrap_integer <- function(x) {
.Call(chunkrep_wrap, x)
}

#' TODO
#'
#' @param df data frame
#'
#' @export
wrap_df <- function(df) {
stopifnot(is.data.frame(df))
Expand Down
1 change: 1 addition & 0 deletions R/relational-rel.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ rel_order <- function(rel, orders, ...) {
#' @param right the right-hand-side relation object
#' @param conds a list of DuckDB expressions to use for the join
#' @param join type of join
#' @param join_ref_type ref type of join
#' @return a new relation object resulting from the join
#' @export
#' @examples
Expand Down
2 changes: 2 additions & 0 deletions R/restore.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' Methods restoring
#'
#' @export
methods_restore <- function() {
vctrs::s3_register("dplyr::add_count", "data.frame", dplyr:::add_count.data.frame)
Expand Down
4 changes: 3 additions & 1 deletion R/stats.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
stats <- new_environment(list(attempts = 0L, fallback = 0L, calls = character()))

#' Show stats
#'
#' @export
stats_show <- function() {
writeLines(paste0(
c("\U0001f6e0", "\U0001f528", "\U0001f986"),
"️: ",
paste0("\u003A", " "),
format(c(stats$attempts, stats$fallback, stats$attempts - stats$fallback))
))
calls <- sort(gsub("[.]duckplyr_df", "", stats$calls))
Expand Down
14 changes: 14 additions & 0 deletions man/as_duckplyr_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/duckdb_from_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/duckplyr_df_from_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/is_duckplyr_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/methods_overwrite.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/methods_restore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/rel_join.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/stats_show.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/wrap_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/wrap_integer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions patch/distinct.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
diff --git b/R/distinct.R a/R/distinct.R
index 1975ca6..3538b76 100644
index 1975ca6..3f246ab 100644
--- b/R/distinct.R
+++ a/R/distinct.R
@@ -3,8 +3,62 @@
@@ -1,10 +1,66 @@
# Generated by 02-duckplyr_df-methods.R
+globalVariables("___row_number_by")
+
#' @export
distinct.duckplyr_df <- function(.data, ..., .keep_all = FALSE) {
# Our implementation
rel_try(
Expand Down
12 changes: 9 additions & 3 deletions patch/filter.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
diff --git b/R/filter.R a/R/filter.R
index 4b91919..36ed7f3 100644
index 4b91919..1ccc3f9 100644
--- b/R/filter.R
+++ a/R/filter.R
@@ -1,10 +1,23 @@
@@ -1,10 +1,28 @@
# Generated by 02-duckplyr_df-methods.R
#' @export
-#' @export
+
+# Needed for R <= 4.2, can't use @export here:
+on_load({
+ vctrs::s3_register("dplyr::filter", "duckplyr_df")
+})
+
filter.duckplyr_df <- function(.data, ..., .by = NULL, .preserve = FALSE) {
- # Our implementation
+ force(.data)
Expand Down
6 changes: 4 additions & 2 deletions patch/summarise.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
diff --git b/R/summarise.R a/R/summarise.R
index 482068f..aea4a71 100644
index 482068f..583d121 100644
--- b/R/summarise.R
+++ a/R/summarise.R
@@ -1,10 +1,50 @@
@@ -1,10 +1,52 @@
# Generated by 02-duckplyr_df-methods.R
+globalVariables("___row_number")
+
#' @export
summarise.duckplyr_df <- function(.data, ..., .by = NULL, .groups = NULL) {
- # Our implementation
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ withr::defer(envir = testthat::teardown_env(), {
writeLines("")
writeLines(format(hms::as_hms(Sys.time() - start)))
})

styler::cache_deactivate()
2 changes: 1 addition & 1 deletion tests/testthat/test-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("no homonyms", {
names_duckplyr <- ls(duckplyr)

names_common <- intersect(names_dplyr, names_duckplyr)
names_common <- setdiff(names_common, "DataMask")
names_common <- setdiff(names_common, c("DataMask", "the"))

objs_dplyr <- mget(names_common, dplyr)
objs_duckplyr <- mget(names_common, duckplyr)
Expand Down
8 changes: 6 additions & 2 deletions tools/02-duckplyr_df-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,18 @@ walk(patches, ~ system(paste0("patch -p1 < ", .x)))

# Stop here to overwrite files if the code generation is updated


system(paste0("git clean -f -- R"))


# Collect new patches -----------------------------------------------------------------

r_status <- gert::git_status(pathspec = "R/*.R")
r_status <- gert::git_status(pathspec = "R/*.R")$file

# Use this to refresh all patches
# r_status <- fs::dir_ls("R", glob = "*.R")

walk(r_status$file, function(file) {
walk(r_status, function(file) {
patch_path <- gsub("R/(.*)[.]R", "patch/\\1.patch", file)
if (fs::file_exists(patch_path)) {
system(paste0("patch -p1 -R < ", patch_path))
Expand Down