luluorta commented on a change in pull request #30625:
URL: https://github.com/apache/spark/pull/30625#discussion_r537196808



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -543,13 +543,14 @@ object LikeSimplification extends Rule[LogicalPlan] {
   private val equalTo = "([^_%]*)".r
 
   def apply(plan: LogicalPlan): LogicalPlan = plan transformAllExpressions {
-    case Like(input, Literal(pattern, StringType), escapeChar) =>
+    case l @ Like(input, Literal(pattern, StringType), escapeChar) =>
       if (pattern == null) {
         // If pattern is null, return null value directly, since "col like 
null" == null.
         Literal(null, BooleanType)
       } else {
         val escapeStr = String.valueOf(escapeChar)
         pattern.toString match {
+          case _ if escapeChar == '_' || escapeChar == '%' => l

Review comment:
       You are right! I think this rule works correctly only if `pattern` is 
valid and `escapeChar` does not escape itself. For simplicity, maybe it's 
better to skip it if `pattern` constains any `escapeChar`. I will fix this and 
change the title/description.




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



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

Reply via email to