Dooyoung-Hwang opened a new pull request #35465:
URL: https://github.com/apache/spark/pull/35465
### What changes were proposed in this pull request?
Currently, LikeSimplification rule is skipped if the pattern in LIKE filter
contains an escape character.
Thus, the filter "LIKE '%100\\%'" in this query is not optimized into
'EndsWith' of StringType.
```
spark.sql("SELECT * FROM tbl LIKE '%100\\%'").explain(true)
...
== Optimized Logical Plan ==
Filter (isnotnull(c_1#0) && c_1#0 LIKE %100\%)
+- Relation[c_1#0,c_2#1,c_3#2]
...
```
LikeSimplification rule can consider a special character(wildcard(%, _) or
escape character) as a plain character if the special character follows an
escape character. By doing that, LikeSimplification rule can optimize the
filter like below.
```
spark.sql("SELECT * FROM tbl LIKE '%100\\%'").explain(true)
...
== Optimized Logical Plan ==
Filter (isnotnull(c_1#0) && EndsWith(c_1#0, 100%))
+- Relation[c_1#0,c_2#1,c_3#2]
```
### Why are the changes needed?
To enhance performance of processing LIKE filters such as "LIKE '%100\\%'",
"LIKE '\\%100\\%'", "LIKE '%\\%100\\%%'", "LIKE '100\\%%'", "LIKE
'100\\%%90\\%'"
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Test suites are added in LikeSimplificationSuite.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]