maropu commented on a change in pull request #30625:
URL: https://github.com/apache/spark/pull/30625#discussion_r537173246
##########
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:
Please add tests in `LikeSimplificationSuite`, too? Btw, does this
simplification work correctly if `escapeChar` is not a default one other than
`_` and `%`?
----------------------------------------------------------------
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]