title: Splitting an array into columns in Athena/Presto
body: <p>I feel this should be simple, but I've struggled to find the right terminology, please bear with me. </p>
  
  <p>I have two columns, <code>timestamp</code> and <code>voltages</code> which is the array</p>
  
  <p>If I do a simple</p>
  
  <pre><code>SELECT timestamp, voltages FROM table
  </code></pre>
  
  <p>Then I'd get a result of:</p>
  
  <p><code>|timestamp |        voltages          |
  |1544435470 |3.7352,3.749,3.7433,3.7533|
  |1544435477 |3.7352,3.751,3.7452,3.7533|
  |1544435484 |3.7371,3.749,3.7433,3.7533|
  |1544435490 |3.7352,3.749,3.7452,3.7533|
  |1544435497 |3.7352,3.751,3.7452,3.7533|
  |1544435504 |3.7352,3.749,3.7452,3.7533|</code></p>
  
  <p>But I want to split the <code>voltages</code> array so each element in its array is its own column. </p>
  
  <p><code>|timestamp  |  v1   |  v2  |   v3  |  v4  |
  |1544435470 |3.7352 |3.749 |3.7433  |3.7533|
  |1544435477 |3.7352 |3.751 |3.7452  |3.7533|
  |1544435484 |3.7371 |3.749 |3.7433  |3.7533|
  |1544435490 |3.7352 |3.749 |3.7452  |3.7533|
  |1544435497 |3.7352 |3.751 |3.7452  |3.7533|
  |1544435504 |3.7352 |3.749 |3.7452  |3.7533|</code></p>
  
  <p>I know I can do this with:</p>
  
  <pre><code>SELECT timestamp, voltages[1] as v1, voltages[2] as v2 FROM table
  </code></pre>
  
  <p>But I'd need to be able to do this programmatically, as opposed to listing them out. </p>
  
  <p>Am I missing something obvious?</p>