title: Split large array columns into multiple columns - Pyspark
body: <p>I have:</p>
  
  <pre class="lang-python prettyprint-override"><code>+---+-------+-------+
  | id|   var1|   var2|
  +---+-------+-------+
  |  a|[1,2,3]|[1,2,3]|
  |  b|[2,3,4]|[2,3,4]|
  +---+-------+-------+
  </code></pre>
  
  <p>I want:</p>
  
  <pre class="lang-python prettyprint-override"><code>+---+-------+-------+-------+-------+-------+-------+
  | id|var1[0]|var1[1]|var1[2]|var2[0]|var2[1]|var2[2]|
  +---+-------+-------+-------+-------+-------+-------+
  |  a|      1|      2|      3|      1|      2|      3|
  |  b|      2|      3|      4|      2|      3|      4|
  +---+-------+-------+-------+-------+-------+-------+
  </code></pre>
  
  <p>The solution provided by <a href="https://stackoverflow.com/questions/45789489/how-to-split-a-list-to-multiple-columns-in-pyspark">How to split a list to multiple columns in Pyspark?</a></p>
  
  <pre class="lang-python prettyprint-override"><code>df1.select('id', df1.var1[0], df1.var1[1], ...).show()
  </code></pre>
  
  <p>works, but some of my arrays are very long (max 332).</p>
  
  <p>How can I write this so that it takes account of all length arrays?</p>