beliefer commented on a change in pull request #25001: [SPARK-28083][SQL]
Support LIKE ... ESCAPE syntax
URL: https://github.com/apache/spark/pull/25001#discussion_r305691039
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala
##########
@@ -39,27 +39,36 @@ object StringUtils extends Logging {
* throw an [[AnalysisException]].
*
* @param pattern the SQL pattern to convert
+ * @param escapeStr the escape string contains one character.
* @return the equivalent Java regular expression of the pattern
*/
- def escapeLikeRegex(pattern: String): String = {
+ def escapeLikeRegex(pattern: String, escapeStr: String): String = {
+ val escapeChar = escapeStr.charAt(0)
val in = pattern.toIterator
val out = new StringBuilder()
def fail(message: String) = throw new AnalysisException(
s"the pattern '$pattern' is invalid, $message")
while (in.hasNext) {
- in.next match {
- case '\\' if in.hasNext =>
+ val cur = in.next
+ if (cur == escapeChar) {
Review comment:
Because only constant could after case, not variable. This will lead a
compile error, when the code as follows:
```
in.next match {
case escapeChar if in.hasNext =>
```
----------------------------------------------------------------
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]