You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/13 08:02:38 UTC

[GitHub] [spark] ulysses-you edited a comment on issue #26860: [SPARK-30230][SQL] Like ESCAPE syntax can not use '_' and '%'

ulysses-you edited a comment on issue #26860: [SPARK-30230][SQL] Like ESCAPE syntax can not use '_' and '%'
URL: https://github.com/apache/spark/pull/26860#issuecomment-565341754
 
 
   If '%' and '_' as escape, how to use the real pattern.
   Like this ?
   ```
   SELECT 'abcd' LIKE 'ab%%' escape '%';
   ```
   
   But actually `StringUtils.escapeLikeRegex` will do this check. It can not run correctly.
   ```
   while (in.hasNext) {
         in.next match {
           case c1 if c1 == escapeChar && in.hasNext =>
             val c = in.next
             c match {
               case '_' | '%' => out ++= Pattern.quote(Character.toString(c))
               case c if c == escapeChar => out ++= Pattern.quote(Character.toString(c))
               case _ => fail(s"the escape character is not allowed to precede '$c'")
             }
           case c if c == escapeChar => fail("it is not allowed to end with the escape character")
           // we will never run these code path
           case '_' => out ++= "."
           case '%' => out ++= ".*"
           case c => out ++= Pattern.quote(Character.toString(c))
         }
       }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org