uros-db commented on code in PR #47154: URL: https://github.com/apache/spark/pull/47154#discussion_r1685755850
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Mode.scala: ########## @@ -106,11 +162,11 @@ case class Mode( val collationAwareBuffer = child.dataType match { Review Comment: and when doing that in a separate function, we should try to follow a logic similar to `RewriteCollationJoin` `getCollationAwareBuffer` can do something like (rough sketch): ``` dataType match { // Short-circuit if there is no collation. case _ if UnsafeRowUtils.isBinaryStable(child.dataType) => ... case st: StringType => getCollationAwareBufferForStringType(...) case at: ArrayType => getCollationAwareBufferForArrayType(...) case st : StructType => getCollationAwareBufferForStructType(...) // Write a comment to point out that don't support MapType (and possibly some other types)... case _ => ... } ``` and then you can have: ``` def getCollationAwareBufferForStringType ... def getCollationAwareBufferForArrayType ... def getCollationAwareBufferForStructType ... ``` that could all rely on `getCollationAwareBuffer` instead of having to call each other for example, imagine if we add support MapType, then with the current approach in this PR: 1. recursivelyGetBufferForStructType would need a case for ArrayType & MapType 2. recursivelyGetBufferForArrayType would need a case for StructType & MapType 3. recursivelyGetBufferForMapType would need a case for ArrayType & StructType (you see where this is going) -- 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