title: Spark combine columns as nested array
body: <p>How can I combine columns in spark as a nested array?</p>
  
  <pre><code>val inputSmall = Seq(
      ("A", 0.3, "B", 0.25),
      ("A", 0.3, "g", 0.4),
      ("d", 0.0, "f", 0.1),
      ("d", 0.0, "d", 0.7),
      ("A", 0.3, "d", 0.7),
      ("d", 0.0, "g", 0.4),
      ("c", 0.2, "B", 0.25)).toDF("column1", "transformedCol1", "column2", "transformedCol2")
  </code></pre>
  
  <p>To something similar as</p>
  
  <pre><code>+-------+---------------+---------------+------- +
  |column1|transformedCol1|transformedCol2|combined|
  +-------+---------------+---------------+------ -+
  |      A|            0.3|            0.3[0.3, 0.3]|
  +-------+---------------+---------------+-------+
  </code></pre>