内容來源:
在hive上執行查詢:
select count(*) from user_active_vv_20110801_31 where
active_type_3>0
union all
active_type_7>0
active_type_9>0
active_type_11>0
active_type_12>0
active_type_17>0
active_type_22>0;
報錯:
failed: error in semantic analysis: top level union
is not supported currently; use a subquery for the union
原來hive不支援頂層union,隻能将union封裝在子查詢中;且必須為union的查詢輸出定義别名,正确的hql如下:
select * from (select count(*) as type3 from
user_active_vv_20110801_31 where
user_active_vv_20110801_31.active_type_3>0
select count(*) as type3 from
user_active_vv_20110801_31 where
user_active_vv_20110801_31.active_type_7>0
select count(*) as type3 from user_active_vv_20110801_31
where user_active_vv_20110801_31.active_type_9>0
where user_active_vv_20110801_31.active_type_11>0
where user_active_vv_20110801_31.active_type_12>0
where user_active_vv_20110801_31.active_type_17>0
where user_active_vv_20110801_31.active_type_22>0) tmp;
執行結果如下:
54211920
57691832
41080830
44067696
32052350
34341676
13968539