miland-db commented on code in PR #45643:
URL: https://github.com/apache/spark/pull/45643#discussion_r1551227337
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -994,15 +994,29 @@ case class StringTranslate(srcExpr: Expression,
matchingExpr: Expression, replac
case class FindInSet(left: Expression, right: Expression) extends
BinaryExpression
with ImplicitCastInputTypes with NullIntolerant {
- override def inputTypes: Seq[AbstractDataType] = Seq(StringType, StringType)
+ final lazy val collationId: Int =
left.dataType.asInstanceOf[StringType].collationId
+
+ override def inputTypes: Seq[AbstractDataType] =
+ Seq(StringTypeAnyCollation, StringTypeAnyCollation)
- override protected def nullSafeEval(word: Any, set: Any): Any =
- set.asInstanceOf[UTF8String].findInSet(word.asInstanceOf[UTF8String])
+ override protected def nullSafeEval(word: Any, set: Any): Any = {
+ if (CollationFactory.fetchCollation(collationId).supportsBinaryEquality) {
+ set.asInstanceOf[UTF8String].findInSet(word.asInstanceOf[UTF8String])
+ } else {
+ set.asInstanceOf[UTF8String].findInSet(word.asInstanceOf[UTF8String],
collationId)
+ }
+ }
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
- nullSafeCodeGen(ctx, ev, (word, set) =>
- s"${ev.value} = $set.findInSet($word);"
- )
+ if (CollationFactory.fetchCollation(collationId).supportsBinaryEquality) {
+ nullSafeCodeGen(ctx, ev, (word, set) => s"${ev.value} =
$set.findInSet($word);")
+ } else {
+ nullSafeCodeGen(ctx, ev, (word, set) => s"${ev.value} =
$set.findInSet($word, $collationId);")
+ }
+ }
+
+ override def checkInputDataTypes(): TypeCheckResult = {
+ super.checkInputDataTypes()
}
Review Comment:
Ok, removed!
--
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]