[R] abandon_ship() looks up `call` with an inheriting get(), so its "no call" guard never fires
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Beginne mit r/R/dplyr-eval.R, besonders mit abandon_ship() im Bereich der Funktionssuche in den Zeilen 252–255, und lies die Kommentare und Tests zu nicht unterstützten dplyr-Ausdrücken in der Nähe. Reproduziere den Wrapper-Fall aus dem Issue und prüfe anschließend das Verhalten mit der vorgeschlagenen nicht vererbenden Suche. Als erledigt gilt die Aufgabe, wenn der Wrapper den dokumentierten Fehler arrow_not_supported auslöst und ein direkter Aufruf seinen bestehenden Fallback beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug, including details regarding any error messages, version, and platform.
When an arrow dplyr verb is reached through a function that forwards ..., and the expression cannot be translated, the user gets
Error in `call$.data <- dplyr::collect(.data)`:
! object of type 'special' is not subsettable
instead of either the documented fallback to R or the arrow_not_supported error that abandon_ship() is written to raise in this situation.
Reproducer
library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
tab <- arrow_table(k = c("a", "a", "b"), v = 1:3)
# Direct call: an expression Arrow cannot translate warns and falls back to R.
summarise(tab, out = dplyr::first(v))
#> Warning: In dplyr::first(v):
#> ℹ Expression not supported in Arrow
#> → Pulling data into R
#> # A tibble: 1 × 1
#> out
#> <int>
#> 1 1
# The same call through a wrapper that forwards `...` errors instead.
wrapper <- function(.data, ...) dplyr::summarise(.data, ...)
wrapper(tab, out = dplyr::first(v))
#> Warning: In dplyr::first(v):
#> ℹ Expression not supported in Arrow
#> → Pulling data into R
#> Error in `call$.data <- dplyr::collect(.data)`:
#> ! object of type 'special' is not subsettable
# The condition carries no Arrow class.
err <- tryCatch(
suppressWarnings(wrapper(tab, out = dplyr::first(v))),
error = identity
)
class(err)
#> [1] "notSubsettableError" "error" "condition"
# What abandon_ship()'s lookup returns when `call` was never bound in `env`:
env <- new.env()
found <- try(get("call", envir = env), silent = TRUE)
identical(found, base::call)
#> [1] TRUE
inherits(found, "try-error")
#> [1] FALSE
# With `inherits = FALSE` the existing guard would fire:
found <- try(get("call", envir = env, inherits = FALSE), silent = TRUE)
inherits(found, "try-error")
#> [1] TRUE
Created on 2026-11-26 with reprex v2.1.1
summarise() is only the example. mutate(), filter() and arrange() fail the same way through an equivalent wrapper, as do grouped queries and RecordBatch input. Only in-memory input is affected: a Dataset through the same wrapper already gets arrow_not_supported, and an expression Arrow can translate works through the wrapper as usual.
Cause
try_arrow_dplyr() captures the verb's call for later use (r/R/dplyr-eval.R#L233-L236):
try(
evalq(call <- match.call(), parent),
silent = !getOption("arrow.debug", FALSE)
)
When the verb's own call contains ..., this match.call() fails with ... used in a situation where it does not exist, so call is never bound in parent. The error is silenced unless options(arrow.debug = TRUE) is set. It does not need arrow to reproduce:
# try_arrow_dplyr()'s capture, reduced to base R.
capture <- function() {
parent <- parent.frame()
try(evalq(call <- match.call(), parent))
exists("call", envir = parent, inherits = FALSE)
}
verb <- function(.data, ...) capture()
wrapper <- function(.data, ...) verb(.data, ...)
verb(1, a = 1)
#> [1] TRUE
wrapper(1, a = 1)
#> Error in match.call() : ... used in a situation where it does not exist
#> [1] FALSE
Created on 2026-11-26 with reprex v2.1.1
abandon_ship() anticipates the missing binding (#L252-L255):
# 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")) {
but get() inherits by default, so the lookup walks out of env and returns base::call. That is not a try-error, the guard is skipped, and execution reaches call$.data <- dplyr::collect(.data), which tries to subset a special. Since R evaluates the right-hand side first, the whole input is collected before the error is raised.
Suggested fix
- call <- try(get("call", envir = env), silent = TRUE)
+ call <- try(get("call", envir = env, inherits = FALSE), silent = TRUE)
With only that line patched in a session, the wrapper gets the classed error and the direct call is unaffected:
library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
# Patch the one lookup in abandon_ship() for this session.
ns <- asNamespace("arrow")
fn <- get("abandon_ship", ns)
src <- deparse(body(fn))
src <- sub(
'get("call", envir = env)',
'get("call", envir = env, inherits = FALSE)',
src,
fixed = TRUE
)
body(fn) <- parse(text = src)[[1]]
assignInNamespace("abandon_ship", fn, ns)
tab <- arrow_table(k = c("a", "a", "b"), v = 1:3)
wrapper <- function(.data, ...) dplyr::summarise(.data, ...)
# Through the wrapper: the classed error the source comments describe.
wrapper(tab, out = dplyr::first(v))
#> Error in `dplyr::first()`:
#> ! Expression not supported in Arrow
#> → Call collect() first to pull data into R.
err <- tryCatch(wrapper(tab, out = dplyr::first(v)), error = identity)
class(err)
#> [1] "arrow_not_supported" "rlang_error" "error"
#> [4] "condition"
# Direct call: the fallback is unchanged.
summarise(tab, out = dplyr::first(v))
#> Warning: In dplyr::first(v):
#> ℹ Expression not supported in Arrow
#> → Pulling data into R
#> # A tibble: 1 × 1
#> out
#> <int>
#> 1 1
Created on 2026-11-26 with reprex v2.1.1
This makes the guard do what it says. It does not make the fallback work through a wrapper: that would need the call captured some other way than match.call() under evalq(), which I have not attempted here.
History
The evalq(call <- match.call(), parent) capture and the inheriting get("call", envir = env) both date from #41576, which changed abandon_ship() to look the call up instead of receiving it as an argument. #43498 then wrapped the match.call() in try(), moved the get() into a try() of its own, and added the inherits(call, "try-error") test, to stop tidyquery's revdep failure seen in #43317. That PR notes that no reproducer could be written at the time; the wrapper above is one, and it shows the guard added there has not been firing.
I ran the code above on 26.0.1.1 only. From reading the source, the same lines are in every CRAN release from 17.0.0 (built from maint-17.0.0-r, which carries #43498) and on main. Up to 16.x, abandon_ship() received the call as an argument and this path did not exist.
Why it matters for calling code
Forwarding ... to a dplyr verb is the ordinary way to write a function or package on top of dplyr, so this is reachable without anything unusual. The resulting notSubsettableError cannot be told apart from any other misuse of $, whereas arrow_not_supported can be caught and names the offending expression.
Versions
- arrow 26.0.1.1 (CRAN)
- dplyr 1.2.1
- R 4.6.2
- macOS 27.2.1, aarch64
Drafted with an AI assistant (Claude). The three code blocks marked as reprex output are unedited output from the versions listed.
Component(s)
R
- Vorherrschende Sprache
- C++
- Sterne
- 17.3k
- Forks
- 4.5k
- Ø Merge
- 3 T. 14 Std.
- Gemergte PRs (30 T.)
- 90
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/arrow
-
[C++][Python][Docs] Some compute functions are missing from the docsEvtl. vergeben @rajbhatt2406-collab hat das vor 1 Tag übernommen. OffenComponent: C++ Component: Documentation Component: Python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/arrow#55762 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Component: C++ Type: enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Component: C++ Type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Component: Continuous Integration Component: Developer Tools Type: enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
apache/arrow#55672 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Component: Python Type: enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
apache/arrow#55659 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Missing repro Platform: Android
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
software-mansion/react-native-reanimated#11554 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Niko1221/Strata#7211 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
sleepyviper1213/redis#52 ·