Skip to content
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
2 changes: 1 addition & 1 deletion r/R/dplyr-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ abandon_ship <- function(err, env) {
.data <- get(".data", envir = env)
# If there's no call (see comment in try_arrow_dplyr), we can't eval with
# dplyr even if the data is in memory already
call <- try(get("call", envir = env), silent = TRUE)
call <- try(get("call", envir = env, inherits = FALSE), silent = TRUE)
if (query_on_dataset(.data) || inherits(call, "try-error")) {
# Add a note suggesting `collect()` to the error message.
# If there are other suggestions already there (with the > arrow name),
Expand Down
22 changes: 22 additions & 0 deletions r/tests/testthat/test-dplyr-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ test_that("try_arrow_dplyr/abandon_ship adds the right message about collect()",
}
})

test_that("abandon_ship errors when the call can't be captured (GH-55793)", {
# Through a wrapper that forwards `...`, try_arrow_dplyr() can't capture the
# call, so abandon_ship() can't fall back to dplyr. It should raise
# arrow_not_supported, as it does for a Dataset.
tab <- arrow_table(x = 1:3)
summarise_wrapper <- function(.data, ...) dplyr::summarise(.data, ...)
mutate_wrapper <- function(.data, ...) dplyr::mutate(.data, ...)

expect_error(
summarise_wrapper(tab, y = dplyr::first(x)),
"Call collect() first to pull data into R",
fixed = TRUE,
class = "arrow_not_supported"
)
expect_error(
mutate_wrapper(tab, y = dplyr::first(x)),
"Call collect() first to pull data into R",
fixed = TRUE,
class = "arrow_not_supported"
)
})

test_that("dplyr verbs error clearly on empty column names", {
skip_if_not_available("acero")
# GH-40303
Expand Down