dragosmg commented on a change in pull request #11473:
URL: https://github.com/apache/arrow/pull/11473#discussion_r732603262
##########
File path: r/R/dplyr-functions.R
##########
@@ -645,6 +645,27 @@ nse_funcs$str_ends <- function(string, pattern, negate =
FALSE) {
out
}
+nse_funcs$str_count <- function(string, pattern) {
+ opts <- get_stringr_pattern_options(enexpr(pattern))
+ if (length(pattern) > 1) {
+ arrow_not_supported("Pattern argument longer than 1")
+ }
+ if (opts$fixed) {
+ out <- Expression$create(
+ "count_substring",
+ string,
+ options = list(pattern = opts$pattern, ignore_case = opts$ignore_case)
+ )
+ } else {
+ out <- Expression$create(
+ "count_substring_regex",
+ string,
+ options = list(pattern = opts$pattern, ignore_case = opts$ignore_case)
+ )
+ }
+ out
+}
Review comment:
~A couple of points:~
* ~I think I should specifically use `return()` to indicate an early return.~
* ~Using `return()` makes the entire expression a bit difficult to read.~
```
return(Expression$create(...))
```
* ~The middle solution would be to still use `out`, but together with
`return()`~
I've changed my mind, going with `return()` and no `out`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]