hive union all

hive union all 问题

20191025


  • (1) hive中使用union all要保证联结的字段类型一致

  • (2)要保持字段名称一致,否则报错Schema of both sides of union should match.

insert into table mytable1
select 
acol1 as mycol1,
acol2 as mycol2
from atable

union all
selest
bcol1 as mycol1,
null as mycol2 -- 即使是null,也要取别名
from btable
  • 也可以都不取别名
insert into table mytable1
select 
acol1,
acol2
from atable

union all
selest
bcol1,
null
from btable

参考

【1】参考资料1
【2】参考资料2

你可能感兴趣的:(hive学习)