title: Spark SQL - Generate array of arrays from the sql function
body: <p>I want to create an array of arrays. This is my data table:</p>
  
  <pre><code>// A case class for our sample table
  case class Testing(name: String, age: Int, salary: Int)
  
  // Create an RDD with some data
  val x = sc.parallelize(Array(
      Testing(null, 21, 905),
      Testing("Noelia", 26, 1130),
      Testing("Pilar", 52,  1890),
      Testing("Roberto", 31, 1450)
   ))
  
  // Convert RDD to a DataFrame 
  val df = sqlContext.createDataFrame(x) 
  
  // For SQL usage we need to register the table
  df.registerTempTable("df")
  </code></pre>
  
  <p>I want to create an array of integer column "age". For that I use "collect_list":</p>
  
  <pre><code>sqlContext.sql("SELECT collect_list(age) as age from df").show
  </code></pre>
  
  <p>But now I want to generate an array containing multiple arrays as created above:</p>
  
  <pre><code> sqlContext.sql("SELECT collect_list(collect_list(age), collect_list(salary)) as arrayInt from df").show
  </code></pre>
  
  <p>But this does not work , or use the function org.apache.spark.sql.functions.array. Any ideas?</p>