cloud-fan commented on a change in pull request #33955:
URL: https://github.com/apache/spark/pull/33955#discussion_r707139228
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -3679,22 +3686,44 @@ case class ArrayUnion(left: Expression, right:
Expression) extends ArrayBinaryLi
body
}
+ def withNaNCheck(body: String): String = {
+ (elementType match {
+ case DoubleType => Some(s"java.lang.Double.isNaN((double)$value)")
+ case FloatType => Some(s"java.lang.Float.isNaN((float)$value)")
+ case _ => None
+ }).map { isNaN =>
+ s"""
+ |if ($isNaN) {
+ | if (!$hashSet.containsNaN()) {
+ | $size++;
+ | $hashSet.addNaN();
+ | $builder.$$plus$$eq($value);
+ | }
+ |} else {
+ | $body
+ |}
+ """.stripMargin
+ }
+ }.getOrElse(body)
+
val processArray = withArrayNullAssignment(
Review comment:
a probably better code style
```
val body = ...
val processArray = withArrayNullAssignment(
s"""
|$jt $value = ${genGetValue(array, i)};
|${withNaNCheck(body)}
```
--
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]