cloud-fan commented on a change in pull request #34848:
URL: https://github.com/apache/spark/pull/34848#discussion_r783632462
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
##########
@@ -480,23 +498,54 @@ abstract class StringPredicate extends BinaryExpression
false
> SELECT _FUNC_('Spark SQL', null);
NULL
+ > SELECT _FUNC_(x'537061726b2053514c', x'537061726b');
+ true
""",
since = "3.3.0",
group = "string_funcs"
)
-case class Contains(left: Expression, right: Expression) extends
StringPredicate {
+object ContainsExpressionBuilder extends BinaryPredicateExpressionBuilderBase {
+ override protected def funcName: String = "contains"
+
+ override protected def createBinaryPredicate(left: Expression, right:
Expression): Expression = {
+ BinaryContains(left, right)
+ }
+
+ override protected def createStringPredicate(left: Expression, right:
Expression): Expression = {
+ Contains(left, right)
+ }
+}
+
+case class Contains(left: Expression, right: Expression)
+ extends StringBinaryPredicate[UTF8String] {
+ override def inputTypes: Seq[AbstractDataType] = Seq(StringType, StringType)
override def compare(l: UTF8String, r: UTF8String): Boolean = l.contains(r)
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
defineCodeGen(ctx, ev, (c1, c2) => s"($c1).contains($c2)")
}
+ override def prettyName: String = "contains"
override protected def withNewChildrenInternal(
newLeft: Expression, newRight: Expression): Contains = copy(left =
newLeft, right = newRight)
}
+case class BinaryContains(left: Expression, right: Expression)
Review comment:
should this just be a `RuntimeReplaceable` and we use `StaticInvoke`
under the hood?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]