title: copy current row , modify it and add a new row in spark
body: <p>I am using spark-sql-2.4.1v with java8 version.
  I have a scenario where I need to copy current row and create another row modifying few columns data how can this be achieved in spark-sql ?</p>
  <p>Ex :
  Given</p>
  <pre><code> val data = List(
    (&quot;20&quot;, &quot;score&quot;, &quot;school&quot;,  14 ,12),
    (&quot;21&quot;, &quot;score&quot;, &quot;school&quot;,  13 , 13),
    (&quot;22&quot;, &quot;rate&quot;, &quot;school&quot;,  11 ,14)
   )
  val df = data.toDF(&quot;id&quot;, &quot;code&quot;, &quot;entity&quot;, &quot;value1&quot;,&quot;value2&quot;)
  </code></pre>
  <p><strong>Current Output</strong></p>
  <pre><code>+---+-----+------+------+------+
  | id| code|entity|value1|value2|
  +---+-----+------+------+------+
  | 20|score|school|    14|    12|
  | 21|score|school|    13|    13|
  | 22| rate|school|    11|    14|
  +---+-----+------+------+------+
  </code></pre>
  <blockquote>
  <p>When column &quot;code&quot; is &quot;rate&quot; copy it as two rows i.e. one is
  original , second it is another row with new code &quot;old_ rate&quot; like
  below</p>
  </blockquote>
  <p><strong>Expected output :</strong></p>
  <pre><code>+---+--------+------+------+------+
  | id|    code|entity|value1|value2|
  +---+--------+------+------+------+
  | 20|   score|school|    14|    12|
  | 21|   score|school|    13|    13|
  | 22|    rate|school|    11|    14|
  | 22|new_rate|school|    11|    14|
  +---+--------+------+------+------+
  </code></pre>
  <p>how to achieve this ?</p>