Hive 中的错误:对于 Exists/Not 存在运算符子查询必须是相关的
Error in Hive : For Exists/Not Exists operator SubQuery must be Correlated
select * from students1;
students1.name students1.age students1.gpa
fred 35 1.28
barney 32 2.32
shyam 32 2.32
select * from students2;
students1.name students1.age
fred 35
barney 32
当我运行这个查询
select
name,age from students1
where not exists
(select name,age from students2);
我收到以下错误消息
Error while compiling statement: FAILED: SemanticException line 39:22
Invalid SubQuery expression 'age' in definition of SubQuery sq_1 [
exists (select name,age from students2) ] used as sq_1 at Line 3:10:
For Exists/Not Exists operator SubQuery must be Correlated.
错误信息很清楚。使用exists
/not exists
.
时子查询应该相关
select name,age
from students1 s1
where not exists (select 1
from students2 s2
where s1.name=s2.name and s1.age=s2.age
)
您正在尝试实现查询的 MINUS
输出。 不幸的是,它在 Hive 中不可用。
您可以在此处阅读 HQL 和 SQL 的限制。 HQL vs SQL
对于不存在的用法,手册中有很好的示例。
subqueries in hive
select * from students1;
students1.name students1.age students1.gpa
fred 35 1.28
barney 32 2.32
shyam 32 2.32
select * from students2;
students1.name students1.age
fred 35
barney 32
当我运行这个查询
select
name,age from students1
where not exists
(select name,age from students2);
我收到以下错误消息
Error while compiling statement: FAILED: SemanticException line 39:22 Invalid SubQuery expression 'age' in definition of SubQuery sq_1 [ exists (select name,age from students2) ] used as sq_1 at Line 3:10: For Exists/Not Exists operator SubQuery must be Correlated.
错误信息很清楚。使用exists
/not exists
.
select name,age
from students1 s1
where not exists (select 1
from students2 s2
where s1.name=s2.name and s1.age=s2.age
)
您正在尝试实现查询的 MINUS
输出。 不幸的是,它在 Hive 中不可用。
您可以在此处阅读 HQL 和 SQL 的限制。 HQL vs SQL
对于不存在的用法,手册中有很好的示例。 subqueries in hive