planga82 commented on a change in pull request #28351:
URL: https://github.com/apache/spark/pull/28351#discussion_r418003415



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/collect.scala
##########
@@ -139,6 +147,35 @@ case class CollectSet(
 
   def this(child: Expression) = this(child, 0, 0)
 
+  /*
+   * SPARK-31500
+   * Array[Byte](BinaryType) Scala equality don't works as expected
+   * so HashSet return duplicates, we have to change types to drop
+   * this duplicates and make collect_set work as expected for this
+   * data type
+   */
+  override lazy val bufferElementType = child.dataType match {
+    case BinaryType => ArrayType(BinaryType)
+    case other => other
+  }
+
+  override def convertToBufferElement(value: Any): Any = {
+    val v = InternalRow.copyValue(value)

Review comment:
       Yes it's true. Cleaner in that way




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to