title: How to convert spark dataframe array to tuple
body: <p>How can I convert spark dataframe to a tuple of 2 in scala?</p>
  
  <p>I tried to explode the array and create a new column with help of lead function, so that I can use two columns to create tuple. </p>
  
  <p>In order to use lead function, I need a column to sort by, I don't have any.
  Please suggest which is best way to solve this?</p>
  
  <p>Note: I need to retain the same order in the array.</p>
  
  <p><strong><em>For example:</em></strong></p>
  
  <p><b>Input</b></p>
  
  <p>For example, input looks something like this,</p>
  
  <pre><code>id1 | [text1, text2, text3, text4]
  
  id2 | [txt, txt2, txt4, txt5, txt6, txt7, txt8, txt9]
  </code></pre>
  
  <p><b>expected o/p: </b>
  I need to get output of tuple of length 2</p>
  
  <pre><code>id1 |  [(text1, text2), (text2, text3), (text3,text4)]
  
  id2 |  [(txt, txt2), (txt2, txt4), (txt4, txt5), (txt5, txt6), (txt6, txt7), (txt7, txt8), (txt8, txt9)]
  </code></pre>