Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/907#discussion_r134035089
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/RegexpUtil.java 
---
    @@ -96,20 +145,46 @@ public static String sqlToRegexLike(
                 || (nextChar == '%')
                 || (nextChar == escapeChar)) {
               javaPattern.append(nextChar);
    +          simplePattern.append(nextChar);
               i++;
             } else {
               throw invalidEscapeSequence(sqlPattern, i);
             }
           } else if (c == '_') {
    +        // if we find _, it is not simple pattern, we are looking for only 
%
    +        notSimple = true;
             javaPattern.append('.');
           } else if (c == '%') {
    +        if (i == 0) {
    +          // % at the start could potentially be one of the simple cases 
i.e. ENDS_WITH.
    +          endsWith = true;
    +        } else if (i == (len-1)) {
    +          // % at the end could potentially be one of the simple cases 
i.e. STARTS_WITH
    +          startsWith = true;
    +        } else {
    +          // If we find % anywhere other than start or end, it is not a 
simple case.
    +          notSimple = true;
    +        }
             javaPattern.append(".");
             javaPattern.append('*');
           } else {
             javaPattern.append(c);
    +        simplePattern.append(c);
           }
         }
    -    return javaPattern.toString();
    +
    +    if (!notSimple) {
    --- End diff --
    
    Yeah, the zillion-flags approach is too complex to follow. Really need a 
good-old state machine.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to