You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug, including details regarding any error messages, version, and platform.
I noticed when reviewing #36720 that we drop the calling environment when evaluating stringr modifier functions. This means potentially unexpected behaviour if one of the arguments is a symbol or function call.
In practice it probably hasn't come up because (1) these arguments are usually literals and not defined by a variable and (2) if they are defined by a variable, that variable is probably in the global environment. The example below fails because int32 is a name in the arrow package namespace.
library(arrow, warn.conflicts=FALSE)
library(dplyr, warn.conflicts=FALSE)
library(stringr)
int32<-"123"
tibble(x="abc123") |>
filter(str_detect(x, regex(int32)))
#> # A tibble: 1 × 1#> x #> <chr> #> 1 abc123
arrow_table(x="abc123") |>
filter(str_detect(x, regex(int32)))
#> Warning: Expression str_detect(x, regex(int32)) not supported in Arrow; pulling#> data into R#> # A tibble: 1 × 1#> x #> <chr> #> 1 abc123
arrow_table(x="abc123") |>
filter(str_detect(x, regex("123")))
#> Table (query)#> x: string#> #> * Filter: match_substring_regex(x, {pattern="123", ignore_case=false})#> See $.data for the source Arrow object
…evaluating (#36784)
### What changes are included in this PR?
Update internals of `get_stringr_pattern_options()` to use `eval_tidy()` instead of `eval()` to ensure we're evaluating things in the right environment.
### Are these changes tested?
Yes
### Are there any user-facing changes?
Yes
* Closes: #36771
Authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
… when evaluating (apache#36784)
### What changes are included in this PR?
Update internals of `get_stringr_pattern_options()` to use `eval_tidy()` instead of `eval()` to ensure we're evaluating things in the right environment.
### Are these changes tested?
Yes
### Are there any user-facing changes?
Yes
* Closes: apache#36771
Authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
dgreiss
pushed a commit
to dgreiss/arrow
that referenced
this issue
Feb 19, 2024
… when evaluating (apache#36784)
### What changes are included in this PR?
Update internals of `get_stringr_pattern_options()` to use `eval_tidy()` instead of `eval()` to ensure we're evaluating things in the right environment.
### Are these changes tested?
Yes
### Are there any user-facing changes?
Yes
* Closes: apache#36771
Authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
Describe the bug, including details regarding any error messages, version, and platform.
I noticed when reviewing #36720 that we drop the calling environment when evaluating stringr modifier functions. This means potentially unexpected behaviour if one of the arguments is a symbol or function call.
arrow/r/R/dplyr-funcs-string.R
Line 65 in be2014a
In practice it probably hasn't come up because (1) these arguments are usually literals and not defined by a variable and (2) if they are defined by a variable, that variable is probably in the global environment. The example below fails because
int32
is a name in the arrow package namespace.Created on 2023-07-19 with reprex v2.0.2
The solution is to use
eval_tidy()
with a data mask instead ofeval()
.Component(s)
R
The text was updated successfully, but these errors were encountered: