title: Coalesce columns in spark dataframe
body: <p>I did an algorithm and I got a lot of columns with the name <em>logic</em> and <em>number suffix</em>, I need to do <code>coalesce</code> but I don't know how to apply <code>coalesce</code> with different amount of columns.</p>
  
  <p>Example:</p>
  
  <pre><code>|id|logic_01|logic_02|logic_03|
  |1 |  null  |a       |null    |  
  |2 |  null  |b       |null    |   
  |3 |   c    | null   |null    |   
  |4 |  null  | null   |d       |
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>|id|logic|
  |1 |  a  |  
  |2 |  b  |   
  |3 |  c  |   
  |4 |  d  | 
  </code></pre>
  
  <p>Another example:</p>
  
  <pre><code>|id|logic_01|logic_02|logic_03|logic_04|
  |1 |  null  |a       |null    |null    |  
  |2 |  null  | null   |null    |b       |   
  |3 |   c    | null   |null    |null    |    
  |4 |  null  | null   |d       |null    |
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>|id|logic|
  |1 |  a  |  
  |2 |  b  |   
  |3 |  c  |   
  |4 |  d  | 
  </code></pre>
  
  <p>Thanks for your help.</p>