title: Hive SQL: Both left and right aliases encountered in JOIN
body: <p>I have this valid T-SQL query:</p>
  
  <pre><code>select t1.*
      ,case when s1.period is not null then 'Y' else 'N' end as flag_cur
      ,case when s2.period is not null then 'Y' else 'N' end as flag_prev
      ,s1.cutoff_date as cutoff_date_cur ,s1.cutoff_dtkey as cutoff_dtkey_cur 
      ,s2.cutoff_date as cutoff_date_prev ,s2.cutoff_dtkey as cutoff_dtkey_prev 
  into #tmp_leads2
  from #tmp_leads t1
  left join #param s1 on s1.period = '(a) Current' and s1.begin_date &lt;= t1.CreatedDate and t1.CreatedDate &lt; s1.end_date 
  left join #param s2 on s2.period = '(b) Previous' and s2.begin_date &lt;= t1.CreatedDate and t1.CreatedDate &lt; s2.end_date 
  </code></pre>
  
  <p>I tried to re-write it for Hive (v0.13) as:</p>
  
  <pre><code>create table tmp_leads2 as  
  select t1.*
      ,case when s1.period is not null then 'Y' else 'N' end as flag_cur
      ,case when s2.period is not null then 'Y' else 'N' end as flag_prev
      ,s1.cutoff_date as cutoff_date_cur ,s1.cutoff_dtkey as cutoff_dtkey_cur 
      ,s2.cutoff_date as cutoff_date_prev ,s2.cutoff_dtkey as cutoff_dtkey_prev 
  from tmp_leads t1
  left join param s1 on s1.period = '(a) Current'  and s1.begin_date &lt;= t1.CreatedDate and t1.CreatedDate &lt; s1.end_date 
  left join param s2 on s2.period = '(b) Previous' and s2.begin_date &lt;= t1.CreatedDate and t1.CreatedDate &lt; s2.end_date ; 
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>Error occurred executing hive query: OK FAILED: SemanticException [Error 10017]: Line 8:53 Both left and right aliases encountered in JOIN 'CreatedDate'
  </code></pre>
  
  <p>I see the fields it's talking about, but I'm not sure how to re-write this while keeping the query results identical.</p>