title: Extracting array index in Spark Dataframe
body: <p>I have a Dataframe with a Column of Array Type
  For example :</p>
  
  <pre><code>val df = List(("a", Array(1d,2d,3d)), ("b", Array(4d,5d,6d))).toDF("ID", "DATA")
  df: org.apache.spark.sql.DataFrame = [ID: string, DATA: array&lt;double&gt;]
  
  scala&gt; df.show
  +---+---------------+
  | ID|           DATA|
  +---+---------------+
  |  a|[1.0, 2.0, 3.0]|
  |  b|[4.0, 5.0, 6.0]|
  +---+---------------+
  </code></pre>
  
  <p>I wish to explode the array and have index like</p>
  
  <pre><code>+---+------------------+
  | ID|  DATA_INDEX| DATA|
  +---+------------------+
  |  a|1           | 1.0 |
  |  a|2           | 2.0 |
  |  a|3           | 3.0 |
  |  b|1           | 4.0 |
  |  b|2           | 5.0 |
  |  b|3           | 6.0 |
  +---+------------+-----+
  </code></pre>
  
  <p>I wish be able to do that with scala, and Sparlyr or SparkR
  I'm using spark 1.6</p>