MaxGekk commented on a change in pull request #27355: [SPARK-30625][SQL]
Support `escape` as third parameter of the `like` function
URL: https://github.com/apache/spark/pull/27355#discussion_r371015061
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
##########
@@ -107,46 +109,65 @@ abstract class StringRegexExpression extends
BinaryExpression
true
> SELECT '%SystemDrive%/Users/John' _FUNC_ '/%SystemDrive/%//Users%'
ESCAPE '/';
true
+ > SELECT _FUNC_('_Apache Spark_', '__%Spark__', '_');
+ true
""",
note = """
Use RLIKE to match with standard regular expressions.
""",
since = "1.0.0")
// scalastyle:on line.contains.tab
-case class Like(left: Expression, right: Expression, escapeChar: Char)
- extends StringRegexExpression {
+case class Like(str: Expression, pattern: Expression, escape: Expression)
+ extends TernaryExpression with StringRegexExpression {
- def this(left: Expression, right: Expression) = this(left, right, '\\')
+ def this(str: Expression, pattern: Expression) = this(str, pattern,
Literal("\\"))
+
+ override def inputTypes: Seq[DataType] = Seq(StringType, StringType,
StringType)
+ override def children: Seq[Expression] = Seq(str, pattern, escape)
+
+ private lazy val escapeChar: Char = if (escape.foldable) {
Review comment:
I got the error when I run new test in `DataFrameFunctionsSuite`.
PrettyAttribute is not foldable.
----------------------------------------------------------------
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]