hive union all

实现的是:增加把一个表的所有行添加到另外一个表中,如果二个表一样,那么表A有5行,表B有10行,那么union all 后就是15行
功能:将两个表中的 相同的字段拼接到一起
特点:union all不去重,数据会重复 ,hive不支持union
union all必须满足如下要求
字段名字一样
字段类型一样
字段个数一样
子表不能有别名
如果需要从合并之后的表中查询数据,那么合并的表必须要有别名

select * from (
select * from m
union all
select * from n
)temp;

如果两张表的字段名不一样,要将一个表修改别名同另一个表的字段名一样。
select * from (
select col1,col2 from m
union all
select col1,col3 as col2 from n
)temp;

并行化执行
每个查询被hive转化成多个阶段,有些阶段关联性不大,则可以并行化执行,减少执行时问。
union all 可以理解是一个job并行 ,通常可以优化,但不绝对

set hive.exec.parallel=true;
set hive.exec.parallel.thread.number=8;

猜你喜欢

转载自blog.csdn.net/weixin_42177380/article/details/90760396