-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R] stringr modifier functions cannot be called with namespace prefix #36720
Comments
Thanks for reporting this @giocomai! In this first example, I think it's how we implemented library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(arrow)
#> Some features are not enabled in this build of Arrow. Run `arrow_info()` for more information.
#>
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#>
#> timestamp
df <- tibble::tibble(x = "eXample")
# dplyr
df %>%
mutate(y = stringr::str_detect(x, pattern = stringr::regex("x", ignore_case = TRUE)))
#> # A tibble: 1 × 2
#> x y
#> <chr> <lgl>
#> 1 eXample TRUE
# doesn't work
arrow_table(df) %>%
mutate(y = stringr::str_detect(x, pattern = stringr::regex("x", ignore_case = TRUE))) %>%
collect()
#> # A tibble: 1 × 2
#> x y
#> <chr> <lgl>
#> 1 eXample FALSE
# works
arrow_table(df) %>%
mutate(y = stringr::str_detect(x, pattern = regex("x", ignore_case = TRUE))) %>%
collect()
#> # A tibble: 1 × 2
#> x y
#> <chr> <lgl>
#> 1 eXample TRUE Created on 2023-07-18 with reprex v2.0.2 |
We have implemented |
We don't have bindings for |
…ace prefix (#36758) ### Rationale for this change Bug in implementation of string modified functions caused them to be swallowed when prefixed with stringr namespace ### What changes are included in this PR? Strips out the `stringr::` prefix when expressions contain `stringr::fixed`, `stringr::coll`, `string::boundary` or `stringr::regex` ### Are these changes tested? Yes ### Are there any user-facing changes? Yes * Closes: #36720 Lead-authored-by: Nic Crane <thisisnic@gmail.com> Co-authored-by: Dewey Dunnington <dewey@dunnington.ca> Signed-off-by: Nic Crane <thisisnic@gmail.com>
…namespace prefix (apache#36758) ### Rationale for this change Bug in implementation of string modified functions caused them to be swallowed when prefixed with stringr namespace ### What changes are included in this PR? Strips out the `stringr::` prefix when expressions contain `stringr::fixed`, `stringr::coll`, `string::boundary` or `stringr::regex` ### Are these changes tested? Yes ### Are there any user-facing changes? Yes * Closes: apache#36720 Lead-authored-by: Nic Crane <thisisnic@gmail.com> Co-authored-by: Dewey Dunnington <dewey@dunnington.ca> Signed-off-by: Nic Crane <thisisnic@gmail.com>
…namespace prefix (apache#36758) ### Rationale for this change Bug in implementation of string modified functions caused them to be swallowed when prefixed with stringr namespace ### What changes are included in this PR? Strips out the `stringr::` prefix when expressions contain `stringr::fixed`, `stringr::coll`, `string::boundary` or `stringr::regex` ### Are these changes tested? Yes ### Are there any user-facing changes? Yes * Closes: apache#36720 Lead-authored-by: Nic Crane <thisisnic@gmail.com> Co-authored-by: Dewey Dunnington <dewey@dunnington.ca> Signed-off-by: Nic Crane <thisisnic@gmail.com>
…namespace prefix (apache#36758) ### Rationale for this change Bug in implementation of string modified functions caused them to be swallowed when prefixed with stringr namespace ### What changes are included in this PR? Strips out the `stringr::` prefix when expressions contain `stringr::fixed`, `stringr::coll`, `string::boundary` or `stringr::regex` ### Are these changes tested? Yes ### Are there any user-facing changes? Yes * Closes: apache#36720 Lead-authored-by: Nic Crane <thisisnic@gmail.com> Co-authored-by: Dewey Dunnington <dewey@dunnington.ca> Signed-off-by: Nic Crane <thisisnic@gmail.com>
Describe the bug, including details regarding any error messages, version, and platform.
When using stringr's
str_detect()
andstr_count()
, stringr's own documentation recommends to usestringr::regex()
andstringr::fixed()
"for finer control of the matching behaviour."This can be used, for example, to set "ignore_case" to TRUE, which is not available as an argument to
str_detect()
directly.The resulting functions have the following structure:
Unfortunately, arguments passed via
stringr::regex()
andstringr::fixed()
are silently ignored byarrow
, which leads to unexpected and quite possibly wrong results.If one prints the arrow call, it is possible to see that indeed even if
ignore_case
is set to TRUE, the call is passed withignore_case
as FALSE.I suppose
arrow
should either get this right, or throw an error.The following reprex (run with arrow version 12.0.1) shows:
ignore.case
argument works nicely when passed via the base functiongrepl
stringr::str_detect()
,stringr::str_count()
(and possibly other stringr functions) throughstringr::regex()
andstringr::str_detect()
(?i)
arrow
throws an error when usingstringi::stri_detect_regex()
(rather thanstringr
) withcase_insensitive = TRUE
(which is still preferrable to ignoring the argument silently).There are obviously many workarounds, but this has led to errors when I applied functions that were not originally written and tested with
arrow
in mind.Created on 2023-07-17 with reprex v2.0.2
Component(s)
R
The text was updated successfully, but these errors were encountered: