配置单元中不支持嵌套子查询

时间:2016-01-21 10:06:47

标签: hadoop

我们在配置单元中尝试了以下查询。但得到错误。请帮我解决这个问题。

select count(1) as OpenItems from issues i , issue_statuses s  

where s.id = i.status_id 

and  s.name NOT IN ('Closed','Passed','Rejected','On 

Hold','Baselined','Completed')

and i.project_id IN 

(select id from projects3 from

CASE WHEN ${projectname} = 'All' then id in

(select p.id from members m, projects3 p ,users_1 u

where m.project_id = p.id and u.id = m.user_id and u.status = '1'

and u.id IN 
(select u1.id from users_1 u1, Supervisor_hierarchy s1 where u1.mail = s1.email and s1.name = ${Superisorname})
group by p.id)
WHEN (${projectname} <>'All' and ${SubProject projectname} ='All') then id 
IN (select id from (select id from project_closure where parent_id in (select id from projects where name = ${projectname}) group by id)a)
WHEN (${SubProject projectname}<>'All' and ${projectname}<> 'All') then id 
IN (select id from(select id from project_closure where id in (select id from projects  where name = ${SubProject projectname}) group by id)a)
END
order by id)

错误:6:5不支持的SubQuery Expression'id':SubQuery表达式引用Parent和SubQuery表达式,并且不是有效的连接条件。

1 个答案:

答案 0 :(得分:0)

  

我知道现在已经很晚了,但却面对任何遇到此问题的人。

当我们遇到以下一个或多个Hive子查询限制时,就会出现此问题。

在这种情况下,对父查询的引用用于Group By子句,该子句属于第4个限制。

Hive子查询限制

  1. 这些子查询仅在表达式的右侧支持。
  2. IN / NOT IN子查询只能选择一列。
  3. EXISTS / NOT EXISTS必须有一个或多个相关谓词。
  4. 仅在子查询的WHERE子句中支持对父查询的引用。
  5. Source: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SubQueries