今天需要对数据进行集合,在hive中发现不能使用union ,只能使用union all
create table hive_test_01(a string,b double);
create table hive_test_02(a string,b double);
insert overwrite table hive_test_01 select 'abc',1 from hive_test limit 1;
insert overwrite table hive_test_02 select 'efg',2 from hive_test limit 1;
hive 在union中不能使用上层的select,只能使用嵌套子查询
select a.a,a.b from
(select m.a,m.b from hive_test_01 m
union all
select n.a,n.b from hive_test_02 n
) a;
执行结果为:
efg 2.0
abc 1.0
union 出现错误。