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/02 07:55:20 UTC

[GitHub] [arrow] projjal commented on a change in pull request #10179: ARROW-12567: [C++][Gandiva] Implement ILIKE SQL function

projjal commented on a change in pull request #10179:
URL: https://github.com/apache/arrow/pull/10179#discussion_r624650624



##########
File path: cpp/src/gandiva/like_holder.cc
##########
@@ -81,20 +81,31 @@ Status LikeHolder::Make(const FunctionNode& node, std::shared_ptr<LikeHolder>* h
       Status::Invalid(
           "'like' function requires a string literal as the second parameter"));
 
-  return Make(arrow::util::get<std::string>(literal->holder()), holder);
+  RE2::Options regex_op;
+  if (node.descriptor()->name() == "ilike") {
+    regex_op.set_case_sensitive(false);  // set case-insensitive for ilike function.
+
+    return Make(arrow::util::get<std::string>(literal->holder()), holder, regex_op);
+  }
+  return Make(arrow::util::get<std::string>(literal->holder()), holder, regex_op);
 }
 
 Status LikeHolder::Make(const std::string& sql_pattern,
-                        std::shared_ptr<LikeHolder>* holder) {
+                        std::shared_ptr<LikeHolder>* holder, RE2::Options regex_op) {
   std::string pcre_pattern;
   ARROW_RETURN_NOT_OK(RegexUtil::SqlLikePatternToPcre(sql_pattern, pcre_pattern));
 
-  auto lholder = std::shared_ptr<LikeHolder>(new LikeHolder(pcre_pattern));
+  std::shared_ptr<LikeHolder> lholder;
+  if (regex_op.case_sensitive()) {

Review comment:
       You can just call ``holder = std::shared_ptr<LikeHolder>(new LikeHolder(pcre_pattern, regex_op));``
   No need for if here




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