title: Add index column to existing Spark's DataFrame
body: <p>I operate with Spark 1.5, using Java. I need to append ID/Index column to existing DataFrame, for example:</p>
  
  <pre><code>+---------+--------+
  |  surname|    name|
  +---------+--------+
  |    Green|    Jake|
  | Anderson|  Thomas|
  | Corleone| Michael|
  |    Marsh|   Randy|
  |  Montana|    Tony|
  |    Green|   Julia|
  |Brenneman|    Eady|
  |   Durden|   Tyler|
  | Corleone|    Vito|
  |   Madiro|     Mat|
  +---------+--------+
  </code></pre>
  
  <p>I want every row to be appended with index, in range between <strong>between 1 and table records amount</strong>. Index order does not matter, any row must just contain unique ID/index. It could be done by transformation into RDD and appending index row and transformation into DataFrame with modified StructType, but, If I understand correctly, this operation consumes a lot of resources for transformation etc., and there must be another way.
  Result must be like:</p>
  
  <pre><code>+---------+--------+---+
  |  surname|    name| id|
  +---------+--------+---+
  |    Green|    Jake|  3|
  | Anderson|  Thomas|  5|
  | Corleone| Michael|  2|
  |    Marsh|   Randy| 10|
  |  Montana|    Tony|  7|
  |    Green|   Julia|  1|
  |Brenneman|    Eady|  2|
  |   Durden|   Tyler|  9|
  | Corleone|    Vito|  4|
  |   Madiro|     Mat|  6|
  +---------+--------+---+
  </code></pre>
  
  <p>Thank you.</p>