title: Spark SQL selecting alias Column on UNION
body: <p>I am doing a Union on a View with itself and then tried to select the alias column i created. </p>
  
  <p>Here is the code i have:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>val mergedDF = sparkSession.sqlContext.sql(" SELECT COLUMN1 as COLUMN3 FROM MY_VIEW Union SELECT COLUMN2 as COLUMN3 from MY_VIEW")
  
  val mergedView = mergedDF.createOrReplaceTempView("MERGED_VIEW")
  
  val distinctColumnDF =sparkSession.sqlContext.sql(" SELECT distinct COLUMN3 from MERGED_VIEW WHERE node like '%city%')
  
  logger.debug("No.of Distinct City Rows="+distinctColumnDF.count());</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am getting the following Error:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>org.apache.spark.sql.catalyst.parser.ParseException: mismatched input 'from' expecting { &lt;EOF&gt;, 'WHERE' , 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LATERAL', 'WINDOW', 'UNION', 'EXCEPT', 'MINUS', 'INTERSECT','SORT','CLUSTER','DISTRIBUTE' }(line 1 , pos 21)
  
  == SQL ==
  
  SELECT distinct COLUMN3 from MERGED_VIEW where node like '%city%'
  ---------------------^^^^</code></pre>
  </div>
  </div>
  </p>
  
  <p>Appreciate any help.</p>
  
  <p>Thanks</p>