dongjoon-hyun commented on a change in pull request #33955:
URL: https://github.com/apache/spark/pull/33955#discussion_r708570515
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -3575,24 +3576,31 @@ case class ArrayUnion(left: Expression, right:
Expression) extends ArrayBinaryLi
if (TypeUtils.typeWithProperEquals(elementType)) {
(array1, array2) =>
val arrayBuffer = new scala.collection.mutable.ArrayBuffer[Any]
- val hs = new OpenHashSet[Any]
- var foundNullElement = false
+ val hs = new SQLOpenHashSet[Any]()
+ val isNaN = SQLOpenHashSet.isNaN(elementType)
Seq(array1, array2).foreach { array =>
var i = 0
while (i < array.numElements()) {
if (array.isNullAt(i)) {
- if (!foundNullElement) {
+ if (!hs.containsNull) {
+ hs.addNull
arrayBuffer += null
- foundNullElement = true
}
} else {
val elem = array.get(i, elementType)
- if (!hs.contains(elem)) {
- if (arrayBuffer.size >
ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH) {
-
ArrayBinaryLike.throwUnionLengthOverflowException(arrayBuffer.size)
+ if (isNaN(elem)) {
+ if (!hs.containsNaN) {
+ arrayBuffer += elem
Review comment:
Ur, BTW, there are multiple `NaN` values which has different bytes from
`Double.NaN`. So, this new semantic is adding the first `NaN` value into the
result, right?
@cloud-fan and @AngersZhuuuu . Do we need to normalize the NaN value by
adding `Double.NaN` or `Float.NaN` always?
--
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]