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

test: Snapshot updates for rcc-smoke (null) #320

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions R/duckplyr-across.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ duckplyr_expand_across <- function(data, quo) {
var <- vars[[i]]

for (j in seq_fns) {
fn_expr <- fn_to_expr(fns[[j]], env)
if (is.function(fn_expr)) {
# We can't translate spliced functions
return(NULL)
}

# Note: `mask` isn't actually used inside this helper
fn_call <- as_across_fn_call(fn_to_expr(fns[[j]], env), var, env, mask = env)
fn_call <- as_across_fn_call(fn_expr, var, env, mask = env)

name <- names[[k]]

Expand Down Expand Up @@ -202,12 +208,13 @@ fn_to_expr <- function(fn, env) {
# Memoize get_ns_exports_lookup() to avoid recomputing the hash of
# every function in every namespace every time
on_load({
get_ns_exports_lookup <<- memoise::memoise(get_ns_exports_lookup)
env <- environment()
assign("get_ns_exports_lookup", memoise::memoise(get_ns_exports_lookup), envir = env)
})

get_ns_exports_lookup <- function(ns) {
names <- getNamespaceExports(ns)
objs <- mget(names, ns)
objs <- mget(names, ns, ifnotfound = list(NULL))
funs <- objs[map_lgl(objs, is.function)]

hashes <- map_chr(funs, hash)
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/duckplyr-across.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Code
test_duckplyr_expand_across(c("x", "y"), across(x:y, function(x) mean(x)))
Output
tibble(x = mean(x), y = mean(y))
NULL

---

Expand All @@ -32,29 +32,29 @@
Code
test_duckplyr_expand_across(c("x", "y"), across(x:y, function(x) mean(x, na.rm = TRUE)))
Output
tibble(x = mean(x, na.rm = TRUE), y = mean(y, na.rm = TRUE))
NULL

---

Code
test_duckplyr_expand_across(c("x", "y", "a"), across(c(a, x), function(x) x + 1))
Output
tibble(a = a + 1, x = x + 1)
NULL

---

Code
test_duckplyr_expand_across(c("x", "y", "a"), across(c(a, x), function(x) x *
2 + 1))
Output
tibble(a = a * 2 + 1, x = x * 2 + 1)
NULL

---

Code
test_duckplyr_expand_across(c("x", "y", "a"), across(-a, function(x) x * x))
Output
tibble(x = x * x, y = y * y)
NULL

---

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-relational-duckdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ test_that("duckdb_rel_from_df()", {
map(df, vec_ptype)
)

# FIXME: Test that vec_ptype_safe() does not materialize (#149),
# remove test-altrep.R

skip_if(Sys.getenv("DUCKPLYR_CHECK_ROUNDTRIP") == "TRUE")

# If this is no longer an eror, we need to make sure that subsetting
Expand Down