thisisnic commented on a change in pull request #11473:
URL: https://github.com/apache/arrow/pull/11473#discussion_r732594952



##########
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:
       Really minor point but I'd refactor this to not use the variable `out` 
as it's not needed - you can just return whichever Expression directly from the 
if/else.




-- 
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]


Reply via email to