title: Type issues when using flatMapGroups
body: <p>I am translating spark-1.6 rdd to spark-2.x datasets</p>
  
  <p>The original code was:</p>
  
  <pre><code>val sample_data : Dataset[(Int, Array[Double])]
  val samples : Array[Array[Array[Double]]] = sample_data.rdd
    .groupBy(x =&gt; x._1)
    .map(x =&gt; {
     val (id: Int, points: Iterable[(Int, Array[Double])]) = x
     val data1 = points.map(x =&gt; x._2).toArray
     data1
  }).collect()
  </code></pre>
  
  <p>The <code>sample_data.rdd</code> no longer works so I am trying to do the same operations using datasets. The new approach uses flatMapGroups</p>
  
  <pre><code>val sample_data : Dataset[(Int, Array[Double])]
  val samples : Array[Array[Array[Double]]] = sample_data
    .groupByKey(x =&gt; x._1)
    .flatMapGroups ( (id: Int, points: Iterable[(Int, Array[Double])]) =&gt;
      Iterator(points.map((x:Int, y:Array[Double]) =&gt; y)).toList
    ).collect()
  </code></pre>
  
  <p>The error given is:</p>
  
  <blockquote>
    <p>Error:(36, 25) overloaded method value map with alternatives:   [B,
    That](f: ((Int, Array[Double])) => B)(implicit bf:
    scala.collection.generic.CanBuildFrom[Iterable[(Int,
    Array[Double])],B,That])That    [B](f: ((Int, Array[Double])) =>
    B)Iterator[B]  cannot be applied to ((Int, Array[Double]) =>
    Array[Double])
            Iterator(points.map((x:Int, y:Array[Double])
     => y)).toList</p>
  </blockquote>
  
  <p>Can you please provide an example of how to use flatMapGroups and how to understand the given error?</p>