Skip to content

Commit

Permalink
restore Make method for LIKE
Browse files Browse the repository at this point in the history
  • Loading branch information
xxlaykxx committed Apr 9, 2024
1 parent 4695c87 commit 9b9e3c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cpp/src/gandiva/regex_functions_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ Result<std::shared_ptr<LikeHolder>> LikeHolder::Make(const FunctionNode& node) {
}
}

Result<std::shared_ptr<LikeHolder>> LikeHolder::Make(const std::string& sql_pattern) {
std::string pcre_pattern;
ARROW_RETURN_NOT_OK(RegexUtil::SqlLikePatternToPcre(sql_pattern, pcre_pattern));

RE2::Options regex_op;
regex_op.set_dot_nl(true); // set dotall mode for the regex.
auto lholder = std::shared_ptr<LikeHolder>(new LikeHolder(pcre_pattern, regex_op));
ARROW_RETURN_IF(!lholder->regex_.ok(),
Status::Invalid("Building RE2 pattern '", pcre_pattern,
"' failed with: ", lholder->regex_.error()));

return lholder;
}

Result<std::shared_ptr<LikeHolder>> LikeHolder::Make(const std::string& sql_pattern,
const std::string& escape_char,
RE2::Options regex_op) {
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/gandiva/regex_functions_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class GANDIVA_EXPORT LikeHolder : public FunctionHolder {

static Result<std::shared_ptr<LikeHolder>> Make(const FunctionNode& node);

static Result<std::shared_ptr<LikeHolder>> Make(const std::string& sql_pattern);

static Result<std::shared_ptr<LikeHolder>> Make(const std::string& sql_pattern,
const std::string& escape_char,
RE2::Options regex_op);
Expand Down

0 comments on commit 9b9e3c7

Please sign in to comment.