title: How to unpack multiple keys in a Spark DataSet
body: <p>I have the following <code>DataSet</code>, with the following structure.</p>
  
  <pre><code>case class Person(age: Int, gender: String, salary: Double)
  </code></pre>
  
  <p>I want to determine the <strong>average</strong> salary by <code>gender</code> and <code>age</code>, thus I group the <code>DS</code> by both keys. I've encountered two main problems, one is that both keys are mixed in a single one, but I want to keep them in two different columns, the other is that the <code>aggregated</code> column gets a silly long name and I can't figure out how to rename it (apparently <code>as</code> and <code>alias</code> won't work) all of this using the <code>DS API</code>.</p>
  
  <pre><code>val df = sc.parallelize(List(Person(100000.00, "male", 27), 
    Person(120000.00, "male", 27), 
    Person(95000, "male", 26),
    Person(89000, "female", 31),
    Person(250000, "female", 51),
    Person(120000, "female", 51)
  )).toDF.as[Person]
  
  df.groupByKey(p =&gt; (p.gender, p.age)).agg(typed.avg(_.salary)).show()
  
  +-----------+------------------------------------------------------------------------------------------------+
  |        key| TypedAverage(line2503618a50834b67a4b132d1b8d2310b12.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$Person)|          
  +-----------+------------------------------------------------------------------------------------------------+ 
  |[female,31]|  89000.0... 
  |[female,51]| 185000.0...
  |  [male,27]| 110000.0...
  |  [male,26]|  95000.0...
  +-----------+------------------------------------------------------------------------------------------------+
  </code></pre>