hvanhovell commented on code in PR #49111: URL: https://github.com/apache/spark/pull/49111#discussion_r1942207117
########## connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala: ########## @@ -471,16 +481,120 @@ private class KeyValueGroupedDatasetImpl[K, V, IK, IV]( } } + private def aggUntypedWithValueMapFunc(columns: TypedColumn[_, _]*): Dataset[_] = { + val originalDs = sparkSession.newDataset(ivEncoder, plan) + + // Apply the value transformation, get a DS of two columns "iv" and "v". + // If any of "iv" or "v" consists of a single primitive field, wrap it with a struct so it + // would not be flattened. + // Also here we detect if the input "iv" is a single field struct. If yes, we rename the field + // to "key" to align with Spark behaviour. + val (valueTransformedDf, ivFields, vFields) = + renameSingleFieldStruct(applyValueMapFunc(originalDs)) + + // Rewrite grouping expressions to use "iv" as input. Review Comment: You could also solve this by generating the key in the map method as well. -- 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