kou commented on code in PR #39441:
URL: https://github.com/apache/arrow/pull/39441#discussion_r1442459501


##########
cpp/src/gandiva/regex_functions_holder.h:
##########
@@ -150,4 +150,27 @@ class GANDIVA_EXPORT ExtractHolder : public FunctionHolder 
{
   int32_t num_groups_pattern_;  // number of groups that user defined inside 
the regex
 };
 
+class GANDIVA_EXPORT RegexLikeHolder : public FunctionHolder {

Review Comment:
   ```suggestion
   class GANDIVA_EXPORT RegexpLikeHolder : public FunctionHolder {
   ```



##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -275,4 +275,77 @@ const char* ExtractHolder::operator()(ExecutionContext* 
ctx, const char* user_in
   return result_buffer;
 }
 
+Result<std::shared_ptr<RegexLikeHolder>> RegexLikeHolder::Make(const 
FunctionNode& node) {
+  ARROW_RETURN_IF(
+      node.children().size() < 2,
+      Status::Invalid("'regex_like' function requires at least two 
parameters"));
+  auto pattern = dynamic_cast<LiteralNode*>(node.children().at(1).get());
+  ARROW_RETURN_IF(
+      pattern == nullptr,
+      Status::Invalid(
+          "'regex_like' function requires a literal as the second parameter"));

Review Comment:
   ```suggestion
             "'regexp_like' function requires a literal as the second 
parameter"));
   ```



##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -275,4 +275,77 @@ const char* ExtractHolder::operator()(ExecutionContext* 
ctx, const char* user_in
   return result_buffer;
 }
 
+Result<std::shared_ptr<RegexLikeHolder>> RegexLikeHolder::Make(const 
FunctionNode& node) {
+  ARROW_RETURN_IF(
+      node.children().size() < 2,
+      Status::Invalid("'regex_like' function requires at least two 
parameters"));

Review Comment:
   ```suggestion
         Status::Invalid("'regexp_like' function requires at least two 
parameters"));
   ```



##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -275,4 +275,77 @@ const char* ExtractHolder::operator()(ExecutionContext* 
ctx, const char* user_in
   return result_buffer;
 }
 
+Result<std::shared_ptr<RegexLikeHolder>> RegexLikeHolder::Make(const 
FunctionNode& node) {
+  ARROW_RETURN_IF(
+      node.children().size() < 2,
+      Status::Invalid("'regex_like' function requires at least two 
parameters"));
+  auto pattern = dynamic_cast<LiteralNode*>(node.children().at(1).get());
+  ARROW_RETURN_IF(
+      pattern == nullptr,
+      Status::Invalid(
+          "'regex_like' function requires a literal as the second parameter"));
+
+  auto pattern_type = pattern->return_type()->id();
+  ARROW_RETURN_IF(
+      !(pattern_type == arrow::Type::STRING || pattern_type == 
arrow::Type::BINARY),
+      Status::Invalid(
+          "'regex_like' function requires a string literal as the second 
parameter"));
+
+  if (node.children().size() > 2) {
+    auto parameter = dynamic_cast<LiteralNode*>(node.children().at(2).get());
+    if (parameter != nullptr) {
+      auto parameter_type = parameter->return_type()->id();
+      ARROW_RETURN_IF(
+          !(parameter_type == arrow::Type::STRING ||
+            parameter_type == arrow::Type::BINARY),
+          Status::Invalid(
+              "'regex_like' function requires a string literal as the third 
parameter"));

Review Comment:
   ```suggestion
                 "'regexp_like' function requires a string literal as the third 
parameter"));
   ```



##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -275,4 +275,77 @@ const char* ExtractHolder::operator()(ExecutionContext* 
ctx, const char* user_in
   return result_buffer;
 }
 
+Result<std::shared_ptr<RegexLikeHolder>> RegexLikeHolder::Make(const 
FunctionNode& node) {
+  ARROW_RETURN_IF(
+      node.children().size() < 2,
+      Status::Invalid("'regex_like' function requires at least two 
parameters"));
+  auto pattern = dynamic_cast<LiteralNode*>(node.children().at(1).get());
+  ARROW_RETURN_IF(
+      pattern == nullptr,
+      Status::Invalid(
+          "'regex_like' function requires a literal as the second parameter"));
+
+  auto pattern_type = pattern->return_type()->id();
+  ARROW_RETURN_IF(
+      !(pattern_type == arrow::Type::STRING || pattern_type == 
arrow::Type::BINARY),
+      Status::Invalid(
+          "'regex_like' function requires a string literal as the second 
parameter"));

Review Comment:
   ```suggestion
             "'regexp_like' function requires a string literal as the second 
parameter"));
   ```



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