title: Spark map dataframe using the dataframe's schema
body: <p>I have a dataframe, created from a JSON object. I can query this dataframe and write it to parquet.</p>
  
  <p>Since I infer the schema, I don't necessarily know what's in the dataframe.</p>
  
  <p>Is there a way to the the column names out or map the dataframe using its own schema?</p>
  
  <pre><code>// The results of SQL queries are DataFrames and support all the normal  RDD operations.
  // The columns of a row in the result can be accessed by field index:
  df.map(t =&gt; "Name: " + t(0)).collect().foreach(println)
  
  // or by field name:
  df.map(t =&gt; "Name: " + t.getAs[String]("name")).collect().foreach(println)
  
  // row.getValuesMap[T] retrieves multiple columns at once into a Map[String, T]
  df.map(_.getValuesMap[Any](List("name", "age"))).collect().foreach(println)
  // Map("name" -&gt; "Justin", "age" -&gt; 19)
  </code></pre>
  
  <p>I would want to do something like</p>
  
  <pre><code>df.map (_.getValuesMap[Any](ListAll())).collect().foreach(println)
  // Map ("name" -&gt; "Justin", "age" -&gt; 19, "color" -&gt; "red")
  </code></pre>
  
  <p>without knowing the actual amount or names of the columns.</p>