niyue commented on code in PR #39441:
URL: https://github.com/apache/arrow/pull/39441#discussion_r1443575394
##########
cpp/src/gandiva/regex_functions_holder.cc:
##########
@@ -275,4 +275,78 @@ const char* ExtractHolder::operator()(ExecutionContext*
ctx, const char* user_in
return result_buffer;
}
+Result<std::shared_ptr<RegexpLikeHolder>> RegexpLikeHolder::Make(
+ const FunctionNode& node) {
+ ARROW_RETURN_IF(
+ node.children().size() < 2,
+ Status::Invalid("'regexp_like' function requires at least two
parameters"));
+ auto pattern = dynamic_cast<LiteralNode*>(node.children().at(1).get());
+ ARROW_RETURN_IF(
+ pattern == nullptr,
+ Status::Invalid(
+ "'regexp_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(
+ "'regexp_like' function requires a string literal as the second
parameter"));
+
+ if (node.children().size() > 2) {
Review Comment:
We may have to return `Invalid` if the number of params is > 3, currently,
the remaining parameters will be silently discarded. Holder like
`RandomGeneratorHolder` checks such requirement at the beginning of this `Make`
function:
```
ARROW_RETURN_IF(node.children().size() > 1,
Status::Invalid("'random' function requires at most one
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]