title: Spark SQL selecting ambiguous column by running a SQL
body: <p>I have a dataframe which is a join of two other dataframes.
  I want to perform a run a SQL query but I don't know how to distinguish the <em>id</em> columns. 
  I tried specifying the original table but no luck.</p>
  
  <p><strong>Schemas</strong>:</p>
  
  <p>blogs:</p>
  
  <pre><code>root
   |-- id: integer (nullable = false)
   |-- author: string (nullable = true)
   |-- title: string (nullable = true)
  </code></pre>
  
  <p>comments:</p>
  
  <pre><code>root
   |-- id: integer (nullable = false)
   |-- blog_id: integer (nullable = false)
   |-- author: string (nullable = true)
   |-- comment: string (nullable = true)
  </code></pre>
  
  <p>blogs joined with comments</p>
  
  <pre><code>root
   |-- id: integer (nullable = true)
   |-- author: string (nullable = true)
   |-- title: string (nullable = true)
   |-- id: integer (nullable = true)
   |-- blog_id: integer (nullable = true)
   |-- author: string (nullable = true)
   |-- comment: string (nullable = true)
  </code></pre>
  
  <p><strong>Attempted queries</strong>:</p>
  
  <pre><code>scala&gt; spark.sql("SELECT id FROM joined")
  12:17:26.981 [run-main-0] INFO org.apache.spark.sql.execution.SparkSqlParser - Parsing command: SELECT id FROM joined
  org.apache.spark.sql.AnalysisException: Reference 'id' is ambiguous, could be: id#7, id#23.; line 1 pos 7
  
  scala&gt; spark.sql("SELECT blogs.id FROM joined")
  org.apache.spark.sql.AnalysisException: cannot resolve '`blogs.id`' given input columns: [blog_id, id, comment, title, author, author, id]; line 1 pos 7;
  'Project ['blogs.id]
  +- SubqueryAlias joined, `joined`
     +- Join FullOuter, (id#7 = blog_id#24)
        :- Project [_1#0 AS id#7, _2#1 AS author#8, _3#2 AS title#9]
        :  +- LocalRelation [_1#0, _2#1, _3#2]
        +- Project [_1#14 AS id#23, _2#15 AS blog_id#24, _3#16 AS author#25, _4#17 AS comment#26]
           +- LocalRelation [_1#14, _2#15, _3#16, _4#17]
  </code></pre>