Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9628#discussion_r44583721
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/GroupedDataset.scala 
---
    @@ -127,15 +125,26 @@ class GroupedDataset[K, T] private[sql](
        */
       def map[U : Encoder](f: (K, Iterator[T]) => U): Dataset[U] = {
         val func = (key: K, it: Iterator[T]) => Iterator(f(key, it))
    -    new Dataset[U](
    -      sqlContext,
    -      MapGroups(func, groupingAttributes, logicalPlan))
    +    flatMap(func)
       }
     
       def map[U](f: MapGroupFunction[K, T, U], encoder: Encoder[U]): 
Dataset[U] = {
         map((key, data) => f.call(key, data.asJava))(encoder)
       }
     
    +  /**
    +   * Reduces the elements of each group of data using the specified binary 
function.
    +   * The given function must be commutative and associative or the result 
may be non-deterministic.
    +   */
    +  def reduce(f: (T, T) => T): Dataset[(K, T)] = {
    +    val func = (key: K, it: Iterator[T]) => Iterator(key -> it.reduce(f))
    +    flatMap(func)(ExpressionEncoder.tuple(kEnc, tEnc))
    --- End diff --
    
    I'm going to pick this up.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to