MaxGekk commented on a change in pull request #27502: [SPARK-30759][SQL] 
Initialize cache for foldable patterns in StringRegexExpression
URL: https://github.com/apache/spark/pull/27502#discussion_r376813496
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
 ##########
 @@ -41,10 +41,12 @@ trait StringRegexExpression extends Expression
 
   override def dataType: DataType = BooleanType
 
-  // try cache the pattern for Literal
+  // try cache foldable pattern
   private lazy val cache: Pattern = pattern match {
-    case Literal(value: String, StringType) => compile(value)
-    case _ => null
+    case p: Expression if p.foldable =>
 
 Review comment:
   The changes don't impact on behavior in any case, so, they can be considered 
only as an optimization. 

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to