两个查询的 Hive Union 给出编译错误
Hive Union of two queries is giving compile error
我不确定下面的配置单元查询有什么问题。但是,它抛出错误。
select h.database_name, h.table_name, h.frequency as hive_frequency, i.frequency as impala_frequency
from hive_access_frequency h
left join impala_access_frequency i
on
h.database_name = i.database_name and
h.table_name = i.table_name
union
select i.database_name, i.table_name, h.frequency as hive_frequency, i.frequency as impala_frequency
from impala_access_frequency i
left join hive_access_frequency h
on
h.database_name = i.database_name and
h.table_name = i.table_name
我可以运行单独查询。但是,在 运行 union
时遇到问题
错误
Error: Error while compiling statement: FAILED: ParseException line 8:0 missing ALL at 'select' near '<EOF>' (state=42000,code=40000)
Hive versions prior to 1.2.0 only support UNION ALL
解决方法:使用 UNION ALL 而不是 UNION,将所有内容包装到子查询中并应用 distinct
select DISTINCT <column_list>
from
(
select ...
UNION ALL
select ...
)s;
UNION 与 UNION ALL + DISTINCT 相同
我不确定下面的配置单元查询有什么问题。但是,它抛出错误。
select h.database_name, h.table_name, h.frequency as hive_frequency, i.frequency as impala_frequency
from hive_access_frequency h
left join impala_access_frequency i
on
h.database_name = i.database_name and
h.table_name = i.table_name
union
select i.database_name, i.table_name, h.frequency as hive_frequency, i.frequency as impala_frequency
from impala_access_frequency i
left join hive_access_frequency h
on
h.database_name = i.database_name and
h.table_name = i.table_name
我可以运行单独查询。但是,在 运行 union
错误
Error: Error while compiling statement: FAILED: ParseException line 8:0 missing ALL at 'select' near '<EOF>' (state=42000,code=40000)
Hive versions prior to 1.2.0 only support UNION ALL
解决方法:使用 UNION ALL 而不是 UNION,将所有内容包装到子查询中并应用 distinct
select DISTINCT <column_list>
from
(
select ...
UNION ALL
select ...
)s;
UNION 与 UNION ALL + DISTINCT 相同