wangyum commented on a change in pull request #29999:
URL: https://github.com/apache/spark/pull/29999#discussion_r519773515
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
##########
@@ -178,6 +179,142 @@ case class Like(left: Expression, right: Expression,
escapeChar: Char)
}
}
+abstract class LikeAllBase extends Expression with ImplicitCastInputTypes {
Review comment:
Could we make it only support `Literal`, for example:
```scala
case class LikeAll(child: Expression, isNotDefined: Boolean, seq:
mutable.Buffer[Any])
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant {
override def dataType: DataType = BooleanType
override def inputTypes: Seq[DataType] = StringType :: Nil
@transient private[this] lazy val hasNull: Boolean = seq.contains(null)
@transient private lazy val cachedPattern = seq.filterNot(_ == null)
.map(s => Pattern.compile(StringUtils.escapeLikeRegex(s.toString, '\\')))
override protected def nullSafeEval(input1: Any): Any = {
if (hasNull) {
false
} else {
val str = input1.asInstanceOf[UTF8String].toString
if (isNotDefined) {
!cachedPattern.exists(p => p.matcher(str).matches())
} else {
cachedPattern.forall(p => p.matcher(str).matches())
}
}
}
// TODO: codegen
}
```
```scala
val exps = ctx.expression.asScala.map(expression)
validate(exps.nonEmpty, "Expected something between '(' and ')'.", ctx)
if (exps.size > 10 && exps.forall(_.foldable)) {
LikeAll(e, isNotDefined, exps.map(_.eval(EmptyRow)))
} else {
exps.map(p => invertIfNotDefined(Like(e, p))).reduceLeft(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]