MCPcopy Create free account
hub / github.com/apache/arrow / Make

Method Make

cpp/src/gandiva/regex_functions_holder.cc:90–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90Result<std::shared_ptr<LikeHolder>> LikeHolder::Make(const FunctionNode& node) {
91 ARROW_RETURN_IF(node.children().size() != 2 && node.children().size() != 3,
92 Status::Invalid("'like' function requires two or three parameters"));
93
94 auto literal = dynamic_cast<LiteralNode*>(node.children().at(1).get());
95 ARROW_RETURN_IF(
96 literal == nullptr,
97 Status::Invalid("'like' function requires a literal as the second parameter"));
98
99 auto literal_type = literal->return_type()->id();
100 ARROW_RETURN_IF(
101 !IsArrowStringLiteral(literal_type),
102 Status::Invalid(
103 "'like' function requires a string literal as the second parameter"));
104
105 RE2::Options regex_op;
106 regex_op.set_dot_nl(true); // set dotall mode for the regex.
107 if (node.descriptor()->name() == "ilike") {
108 regex_op.set_case_sensitive(false); // set case-insensitive for ilike function.
109
110 return Make(std::get<std::string>(literal->holder()), regex_op);
111 }
112 if (node.children().size() == 2) {
113 return Make(std::get<std::string>(literal->holder()), regex_op);
114 } else {
115 auto escape_char = dynamic_cast<LiteralNode*>(node.children().at(2).get());
116 ARROW_RETURN_IF(
117 escape_char == nullptr,
118 Status::Invalid("'like' function requires a literal as the third parameter"));
119
120 auto escape_char_type = escape_char->return_type()->id();
121 ARROW_RETURN_IF(
122 !IsArrowStringLiteral(escape_char_type),
123 Status::Invalid(
124 "'like' function requires a string literal as the third parameter"));
125 return Make(std::get<std::string>(literal->holder()),
126 std::get<std::string>(escape_char->holder()), regex_op);
127 }
128}
129
130Result<std::shared_ptr<LikeHolder>> LikeHolder::Make(const std::string& sql_pattern) {
131 std::string pcre_pattern;

Callers

nothing calls this directly

Calls 12

IsArrowStringLiteralFunction · 0.85
SqlLikePatternToPcreFunction · 0.85
MakeFunction · 0.70
InvalidFunction · 0.50
sizeMethod · 0.45
childrenMethod · 0.45
getMethod · 0.45
idMethod · 0.45
return_typeMethod · 0.45
nameMethod · 0.45
okMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected