ianmcook commented on a change in pull request #10190:
URL: https://github.com/apache/arrow/pull/10190#discussion_r626019761
##########
File path: r/R/dplyr.R
##########
@@ -540,6 +542,31 @@ arrow_stringr_string_replace_function <- function(FUN,
max_replacements) {
}
}
+arrow_r_string_split_function <- function(FUN, reverse = FALSE, max_splits =
-1){
+ function(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE){
+
+ assert_that(is.string(split))
+
+ # if !fixed but no regex metachars in split pattern, allow to proceed as
split isn't regex
+ if(!fixed && contains_regex(split)){
+ stop("Regular expression matching not supported in strsplit for Arrow",
call. = FALSE)
+ }
+ if(fixed && perl){
+ warning("argument 'perl = TRUE' will be ignored")
+ }
+ FUN("split_pattern", x, options = list(pattern = split, reverse = reverse,
max_splits = max_splits))
+ }
+}
+
+arrow_stringr_string_split_function <- function(FUN, reverse = FALSE){
+ function(string, pattern, n = 0){
+ if(contains_regex(pattern)){
+ stop("Regular expression matching not supported in str_split() for
Arrow", call. = FALSE)
+ }
+ FUN("split_pattern", string, options = list(pattern = pattern, reverse =
reverse, max_splits = n-1))
Review comment:
Ok, here's the strange non-standard eval stuff I mentioned earlier,
which we need to use to support the stringr pattern modifier functions (see
`?stringr::modifiers`). Let me know if you have any trouble following this and
we can chat about it.
```suggestion
opts <- get_stringr_pattern_options(enexpr(pattern))
if (!opts$fixed && contains_regex(opts$pattern)) {
stop("Regular expression matching not supported in str_split() for
Arrow", call. = FALSE)
}
if (opts$ignore_case) {
stop("Case-insensitive string splitting not supported in Arrow", call.
= FALSE)
}
FUN("split_pattern", string, options = list(pattern = opts$pattern,
reverse = reverse, max_splits = n - 1))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]