Skip to content
Merged
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/R/dplyr-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ try_arrow_dplyr <- function(expr) {
parent <- caller_env()
# Make sure that the call is available in the parent environment
# so that we can use it in abandon_ship, if needed
evalq(call <- match.call(), parent)
# (but don't error if we're in some weird context where we can't get the call,
# which could happen if you're code-generating or something?)
try(
evalq(call <- match.call(), parent),
silent = !getOption("arrow.debug", FALSE)
)

tryCatch(
eval(expr, parent),
Expand All @@ -217,7 +222,10 @@ try_arrow_dplyr <- function(expr) {
# and that the function being called also exists in the dplyr namespace.
abandon_ship <- function(err, env) {
.data <- get(".data", envir = env)
if (query_on_dataset(.data)) {
# 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)
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),
# collect() isn't the only suggestion, so message differently
Expand All @@ -231,7 +239,6 @@ abandon_ship <- function(err, env) {
}

# Else, warn, collect(), and run in regular dplyr
call <- get("call", envir = env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised by this deletion, was this essentially overwritting what was in call when it ran? Or something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved it up to L227

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AAAAAH I totally missed that. Thanks

rlang::warn(
message = paste0("In ", format_expr(err$call), ": "),
body = c("i" = conditionMessage(err), ">" = "Pulling data into R")
Expand Down