mkaravel commented on code in PR #52316:
URL: https://github.com/apache/spark/pull/52316#discussion_r2347027423


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/datasketchesAggregates.scala:
##########
@@ -146,8 +151,11 @@ case class HllSketchAgg(
         case IntegerType => sketch.update(v.asInstanceOf[Int])
         case LongType => sketch.update(v.asInstanceOf[Long])
         case st: StringType =>
-          val cKey = 
CollationFactory.getCollationKey(v.asInstanceOf[UTF8String], st.collationId)
-          sketch.update(cKey.toString)
+          val str = v.asInstanceOf[UTF8String]
+          if (str != null && str.numBytes > 0) {
+            val cKey = CollationFactory.getCollationKeyBytes(str, 
st.collationId)
+            sketch.update(cKey)
+          }

Review Comment:
   It might be helpful to look at the `buildCollation` method:
   
https://github.com/apache/spark/blob/master/common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java#L589
   
   This is where the `sortKeyFunction` is set.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to