Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19811#discussion_r157797472
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
 ---
    @@ -112,15 +112,15 @@ case class Like(left: Expression, right: Expression) 
extends StringRegexExpressi
       override protected def doGenCode(ctx: CodegenContext, ev: ExprCode): 
ExprCode = {
         val patternClass = classOf[Pattern].getName
         val escapeFunc = StringUtils.getClass.getName.stripSuffix("$") + 
".escapeLikeRegex"
    -    val pattern = ctx.freshName("pattern")
     
         if (right.foldable) {
           val rVal = right.eval()
           if (rVal != null) {
             val regexStr =
               
StringEscapeUtils.escapeJava(escape(rVal.asInstanceOf[UTF8String].toString()))
    -        ctx.addMutableState(patternClass, pattern,
    -          s"""$pattern = ${patternClass}.compile("$regexStr");""")
    +        // inline mutable state since not many Like operations in a task
    --- End diff --
    
    I'm not very sure about this, since `Like` is an expression and can appear 
many times, like other expressions.


---

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

Reply via email to