AngersZhuuuu commented on a change in pull request #33993:
URL: https://github.com/apache/spark/pull/33993#discussion_r709243579
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -3410,32 +3410,63 @@ case class ArrayDistinct(child: Expression)
}
override def nullSafeEval(array: Any): Any = {
- val data = array.asInstanceOf[ArrayData].toArray[AnyRef](elementType)
+ val data = array.asInstanceOf[ArrayData]
doEvaluation(data)
}
@transient private lazy val doEvaluation = if
(TypeUtils.typeWithProperEquals(elementType)) {
- (data: Array[AnyRef]) => new
GenericArrayData(data.distinct.asInstanceOf[Array[Any]])
+ (array: ArrayData) =>
+ val arrayBuffer = new scala.collection.mutable.ArrayBuffer[Any]
+ val hs = new SQLOpenHashSet[Any]()
+ val isNaN = SQLOpenHashSet.isNaN(elementType)
+ var i = 0
+ while (i < array.numElements()) {
+ if (array.isNullAt(i)) {
+ if (!hs.containsNull) {
+ hs.addNull
+ arrayBuffer += null
+ }
+ } else {
+ val elem = array.get(i, elementType)
+ if (isNaN(elem)) {
+ if (!hs.containsNaN) {
+ arrayBuffer += elem
Review comment:
> For this, let's wait for the decision at the first PR.
>
> * https://github.com/apache/spark/pull/33955/files#r708570515
Done
--
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]