Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/14222#discussion_r71058680 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala --- @@ -177,10 +178,33 @@ class KeyValueGroupedDataset[K, V] private[sql]( * @since 1.6.0 */ def reduceGroups(f: (V, V) => V): Dataset[(K, V)] = { - val func = (key: K, it: Iterator[V]) => Iterator((key, it.reduce(f))) + val encoder = encoderFor[V] + val intEncoder: ExpressionEncoder[Int] = ExpressionEncoder() + val aggregator: TypedColumn[V, V] = new Aggregator[V, (Int, V), V] { + def bufferEncoder: Encoder[(Int, V)] = ExpressionEncoder.tuple(intEncoder, encoder) + def outputEncoder: Encoder[V] = encoder - implicit val resultEncoder = ExpressionEncoder.tuple(kExprEnc, vExprEnc) - flatMapGroups(func) + def zero: (Int, V) = (0, null.asInstanceOf[V]) --- End diff -- ok. I will update this.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org