title: What is the similar alternative to reduceByKey in DataFrames
body: <p>Give following code</p>
  
  <pre><code>case class Contact(name: String, phone: String)
  case class Person(name: String, ts:Long, contacts: Seq[Contact])
  
  val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
  import sqlContext.implicits._
  val people = sqlContext.read.format("orc").load("people")
  </code></pre>
  
  <p>What is the best way to dedupe users by its timestamp
  So the user with max ts will stay at collection?
  In spark using RDD I would run something like this </p>
  
  <pre><code>rdd.reduceByKey(_ maxTS _) 
  </code></pre>
  
  <p>and would add the maxTS method to Person or add implicits ...</p>
  
  <pre><code>def maxTS(that: Person):Person =
  that.ts &gt; ts match {
    case true =&gt; that
    case false =&gt; this
  }
  </code></pre>
  
  <p>Is it possible to do the same at DataFrames? and will that be the similar performance? 
  We are using spark 1.6</p>