1
我有這個有效的T-SQL查詢:蜂巢SQL:左,右別名遇到JOIN
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 <= t1.CreatedDate and t1.CreatedDate < s1.end_date
left join #param s2 on s2.period = '(b) Previous' and s2.begin_date <= t1.CreatedDate and t1.CreatedDate < s2.end_date
我試圖重新寫吧蜂巢(V0.13)爲:
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 <= t1.CreatedDate and t1.CreatedDate < s1.end_date
left join param s2 on s2.period = '(b) Previous' and s2.begin_date <= t1.CreatedDate and t1.CreatedDate < s2.end_date ;
但我得到的錯誤:
Error occurred executing hive query: OK FAILED: SemanticException [Error 10017]: Line 8:53 Both left and right aliases encountered in JOIN 'CreatedDate'
我看到它在談論的領域,但我不敢肯定,同時保持查詢結果如何重新寫s相同。