title: Select field only if it exists (SQL or Scala)
body: <p>The input dataframe may not always have all the columns. In SQL or SCALA, I want to create a select statement where even if the dataframe does not have column, it won't error out and it will only output the columns that do exist.</p>
  
  <p>For example, this statement will work.</p>
  
  <pre><code>Select store, prod, distance from table
  
  +-----+------+--------+
  |store|prod  |distance|
  +-----+------+--------+
  |51   |42    |2     |
  |51   |42    |5     |
  |89   |44    |9     |
  </code></pre>
  
  <p>If the dataframe looks like below, I want the same statement to work, to just ignore what's not there, and just output the existing columns (in this case 'store' and 'prod')</p>
  
  <pre><code>+-----+------+
  |store|prod  |
  +-----+------+
  |51   |42    |
  |51   |42    |
  |89   |44    |
  </code></pre>