You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/20 21:33:35 UTC

[GitHub] [arrow] ianmcook commented on a change in pull request #10369: ARROW-12835: [C++][Python][R] Implement case-insensitive match using RE2

ianmcook commented on a change in pull request #10369:
URL: https://github.com/apache/arrow/pull/10369#discussion_r636484360



##########
File path: r/R/dplyr-functions.R
##########
@@ -139,11 +139,11 @@ nse_funcs$str_trim <- function(string, side = c("both", "left", "right")) {
 }
 
 nse_funcs$grepl <- function(pattern, x, ignore.case = FALSE, fixed = FALSE) {
-  arrow_fun <- ifelse(fixed && !ignore.case, "match_substring", "match_substring_regex")
+  arrow_fun <- ifelse(fixed, "match_substring", "match_substring_regex")
   Expression$create(
     arrow_fun,
     x,
-    options = list(pattern = format_string_pattern(pattern, ignore.case, fixed))
+    options = list(pattern = pattern, ignore.case = ignore.case)

Review comment:
       Tiny little nit: let's make it `ignore_case` with an underscore inside the options list (but leave it with a dot in the R function args for compatibility with R's `grepl()` function
   ```suggestion
       options = list(pattern = pattern, ignore_case = ignore.case)
   ```

##########
File path: r/src/compute.cpp
##########
@@ -219,7 +219,8 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
 
   if (func_name == "match_substring" || func_name == "match_substring_regex") {
     using Options = arrow::compute::MatchSubstringOptions;
-    return std::make_shared<Options>(cpp11::as_cpp<std::string>(options["pattern"]));
+    return std::make_shared<Options>(cpp11::as_cpp<std::string>(options["pattern"]),
+                                     cpp11::as_cpp<bool>(options["ignore.case"]));

Review comment:
       Please make the `ignore_case` option optional here, and switch to using underscores 
   ```suggestion
       bool ignore_case = false;
       if (!Rf_isNull(options["ignore_case"])) {
         ignore_case = cpp11::as_cpp<bool>(options["ignore_case"]);
       }
       return std::make_shared<Options>(cpp11::as_cpp<std::string>(options["pattern"]),
                                        ignore_case);
   ```




-- 
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:
users@infra.apache.org