wjones127 commented on a change in pull request #8844:
URL: https://github.com/apache/arrow/pull/8844#discussion_r606019594
##########
File path: cpp/src/gandiva/regex_util.cc
##########
@@ -30,8 +30,14 @@ Status RegexUtil::SqlLikePatternToPcre(const std::string&
sql_pattern, char esca
for (size_t idx = 0; idx < sql_pattern.size(); ++idx) {
auto cur = sql_pattern.at(idx);
+ if (idx == 0 && cur != '%') {
+ pcre_pattern += '^';
+ } else if (idx == 0 && cur == '%') {
+ continue;
+ }
+
// Escape any char that is special for pcre regex
- if (pcre_regex_specials_.find(cur) != pcre_regex_specials_.end()) {
+ if (pcre_regex_specials_.find(cur) != pcre_regex_specials_.end() && cur !=
escape_char) {
Review comment:
This change enables using `\` as an escape character in LIKE statements.
For example, `col like '\_%'` can match anything starting with an underscore.
--
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:
[email protected]