cloud-fan commented on a change in pull request #30465:
URL: https://github.com/apache/spark/pull/30465#discussion_r528554387
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
##########
@@ -255,11 +265,67 @@ abstract class LikeAllBase extends UnaryExpression with
ImplicitCastInputTypes w
}
case class LikeAll(child: Expression, patterns: Seq[UTF8String]) extends
LikeAllBase {
- override def isNotLikeAll: Boolean = false
+ override def isNotSpecified: Boolean = false
}
case class NotLikeAll(child: Expression, patterns: Seq[UTF8String]) extends
LikeAllBase {
- override def isNotLikeAll: Boolean = true
+ override def isNotSpecified: Boolean = true
+}
+
+/**
+ * Optimized version of LIKE ANY, when all pattern values are literal.
+ */
+abstract class LikeAnyBase extends MultiLikeBase {
+
+ override def matches(exprValue: String): Any = {
+ if (cache.exists(matchFunc(_, exprValue))) {
+ true
+ } else {
+ if (hasNull) null else false
+ }
+ }
+
+ override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
+ val eval = child.genCode(ctx)
+ val patternClass = classOf[Pattern].getName
+ val javaDataType = CodeGenerator.javaType(child.dataType)
+ val pattern = ctx.freshName("pattern")
+ val valueArg = ctx.freshName("valueArg")
+ val patternCache = ctx.addReferenceObj("patternCache", cache.asJava)
+
+ val checkMatchCode = if (isNotSpecified) {
Review comment:
this can be put in the base trait as well.
----------------------------------------------------------------
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]