title: Spark Error: Unable to find encoder for type stored in a Dataset
body: <p>I am using Spark on a Zeppelin notebook, and groupByKey() does not seem to be working. </p>
  
  <p>This code: </p>
  
  <pre><code>df.groupByKey(row =&gt; row.getLong(0))
    .mapGroups((key, iterable) =&gt; println(key))
  </code></pre>
  
  <p>Gives me this error (presumably a compilation error, since it shows up in no time while the dataset I am working on is pretty big): </p>
  
  <pre><code>error: Unable to find encoder for type stored in a Dataset.  Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._  Support for serializing other types will be added in future releases.
  </code></pre>
  
  <p>I tried to add a case class and map all of my rows into it, but still got the same error</p>
  
  <pre><code>import spark.implicits._
  
  case class DFRow(profileId: Long, jobId: String, state: String)
  
  def getDFRow(row: Row):DFRow = {
      return DFRow(row.getLong(row.fieldIndex("item0")),
                   row.getString(row.fieldIndex("item1")), 
                   row.getString(row.fieldIndex("item2")))
  }
  
  df.map(DFRow(_))
    .groupByKey(row =&gt; row.getLong(0))
    .mapGroups((key, iterable) =&gt; println(key))
  </code></pre>
  
  <p>The schema of my Dataframe is:</p>
  
  <pre><code>root
  |-- item0: long (nullable = true)
  |-- item1: string (nullable = true)
  |-- item2: string (nullable = true)
  </code></pre>