title: How can I round a column in a Spark Dataset?
body: <p>using Scala Spark, how can I use the typed Dataset API to round an aggregated column?</p>
  
  <p>Also, how can I retain the type of a dataset through a groupby operation?</p>
  
  <p>This is what I currently have:</p>
  
  <pre><code>case class MyRow(
    k1: String,
    k2: String,
    c1: Double,
    c2: Double
  )
  
  def groupTyped(ds: Dataset[MyRow]): Dataset[MyRow] = {
  import org.apache.spark.sql.expressions.scalalang.typed._
  ds.groupByKey(row =&gt; (row.k1, row.k2))
    .agg(
      avg(_.c1),
      avg(_.c2)
    )
    .map(r =&gt; MyRow(r._1._1, r._1._2, r._2, r._3))
  }
  </code></pre>
  
  <ol>
  <li>if I replace the <code>avg(_.c1)</code> with a <code>round(avg(_.c1))</code> I get a type error. What's the correct way to round my values?</li>
  <li>the <code>.map(...)</code> line does not feel right -- is there a more elegant way to retain my Dataset's type?</li>
  </ol>
  
  <p>Thanks!</p>