Github user tarekauel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7561#discussion_r35074087
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
 ---
    @@ -187,6 +187,64 @@ case class Like(left: Expression, right: Expression)
       override def matches(regex: Pattern, str: String): Boolean = 
regex.matcher(str).matches()
     
       override def toString: String = s"$left LIKE $right"
    +
    +  override protected def genCode(ctx: CodeGenContext, ev: 
GeneratedExpressionCode): String = {
    +    val patternClass = classOf[Pattern].getName
    +
    +    val literalRight: String = right match {
    +      case x @ Literal(value: String, StringType) => escape(value)
    +      case _ => null
    +    }
    +
    +    val leftGen = left.gen(ctx)
    +    val rightGen = right.gen(ctx)
    +
    +    val patternCode =
    +      if (literalRight != null) {
    +        s"${patternClass} pattern = $patternClass.compile($literalRight);"
    +      } else {
    +        s"""
    +          StringBuilder regex = new StringBuilder("(?s)");
    --- End diff --
    
    I am not sure, if `StringBuilder`is imported. If not define somewhere `val 
sb = classOf[StringBuilder].getName` and use `$sb`
    
    You shouldn't use `regex`. You can create a save variable name with 
`ctx.freshName`


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to