uros-db commented on code in PR #46597:
URL: https://github.com/apache/spark/pull/46597#discussion_r1605136854


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Mode.scala:
##########
@@ -74,16 +80,28 @@ case class Mode(
     if (buffer.isEmpty) {
       return null
     }
-
+    val collationAwareBuffer =
+      if 
(!CollationFactory.fetchCollation(collationId).supportsBinaryEquality) {
+        val modeMap = buffer.toSeq.groupMapReduce {
+          case (key: String, _) =>
+            CollationFactory.getCollationKey(UTF8String.fromString(key), 
collationId)
+          case (key: UTF8String, _) =>
+            CollationFactory.getCollationKey(key, collationId)
+          case (key, _) => key
+        }(x => x)((x, y) => (x._1, x._2 + y._2)).values
+        modeMap
+      } else {
+        buffer
+      }

Review Comment:
   ```suggestion
       val collationAwareBuffer = child.dataType match {
         case st: StringType =>
             val modeMap = buffer.toSeq.groupMapReduce {
             case (key: String, _) =>
               CollationFactory.getCollationKey(UTF8String.fromString(key), 
collationId)
             case (key: UTF8String, _) =>
               CollationFactory.getCollationKey(key, collationId)
             case (key, _) => key
             }(x => x)((x, y) => (x._1, x._2 + y._2)).values
             modeMap
         case _ => buffer
       }
   ```
   
   (something like this)



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