beliefer commented on a change in pull request #25001: [SPARK-28083][SQL]
Enhance ANSI SQL: LIKE predicate: ESCAPE clause.
URL: https://github.com/apache/spark/pull/25001#discussion_r299428024
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
##########
@@ -65,6 +65,59 @@ abstract class StringRegexExpression extends
BinaryExpression
override def sql: String = s"${left.sql}
${prettyName.toUpperCase(Locale.ROOT)} ${right.sql}"
}
+abstract class StringRegexV2Expression extends TernaryExpression
Review comment:
This way exists a problem escape character could not pass to the
`nullSafeCodeGen`.
```
nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
s"""
String $patternStr = $eval2.toString();
Character $escapeChar = ?
$patternClass $pattern =
$patternClass.compile($escapeFunc($patternStr, $escapeChar));
${ev.value} = $pattern.matcher($eval1.toString()).matches();
"""
})
```
not like
```
nullSafeCodeGen(ctx, ev, (eval1, eval2, eval3) => {
s"""
String $rightStr = $eval2.toString();
$patternClass $pattern =
$patternClass.compile($escapeFunc($rightStr));
String $patternStr = $eval2.toString();
Character $escapeChar = $eval3.toString().charAt(0);
$patternClass $pattern =
$patternClass.compile($escapeFunc($patternStr, $escapeChar));
${ev.value} = $pattern.matcher($eval1.toString()).matches();
"""
})
```
If I ignore some details, tell me please.
----------------------------------------------------------------
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]