Describe the bug, including details regarding any error messages, version, and platform.
When running the example below foo.R with source("foo.R", local = new.env()), the object pattern is not found by arrow while it is defined in this new environment. It seems arrow doesn't search the objects in the correct environment when using case_when().
The same code using dplyr instead of arrow works fine. The arrow code also works fine interactively or with source() only.
foo.R:
library(arrow)
library(dplyr)
dat <- arrow_table(x = c("a", "b", "c"))
pattern <- "a"
dat |>
mutate(x2 = case_when(pattern == "a" ~ "foo")) |>
collect()
R 4.5.0
arrow 19.0.1.1
Component(s)
R