使用HIVE进行union操作,
select col1,col2 from table_name1
union
select col1,col2 from table_name2
在运行时报错,错误信息为:
- ERROR Error while compiling statement: FAILED: ParseException line 3:0 missing ALL at 'select' near ''
提示少了 ALL。通过查询官方union的用法说明知,Hive在1.2.0之前的版本只支持union all,在1.2.0之后的版本才支持union.
解决办法:使用union all,然后外边套一层 select distinct 实现去重。