在HIVE中遇到0个孩子错误的SemanticException IN

时间:2018-04-20 15:55:10

标签: join hiveql in-subquery

Select t.id, sa.APPLICATION_ID, c.CODE_SID  
from table1 t 
join table2 c 
on c.ID = t.COSTTYPE 
and  c.TYPE_LIST_ID 
IN (Select typel.TYPE_LIST_ID 
     from table3 typel
     where typel.TYPELIST_TABLE_NAME = 'a' )
join table4 tl 
    on t.id = tl.id 
join table5 sa 
where sa.sourcename='GW' and sa.SYSTEM_APPLICATION_SHORT_NAME = 'B'

我正在尝试在Hive中执行此操作但是我得到并且错误地说0个孩子遇到SemanticException IN。所以问题在于IN(Select .......)。有没有其他方法可以在不使用IN子句的情况下编写查询?感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我认为您的IN子句的问题在于它是在WHERE子句之外声明的?尝试将这部分移到WHERE子句中,如下所示:

Select t.id, sa.APPLICATION_ID, c.CODE_SID  
from table1 t 
join table2 c 
on c.ID = t.COSTTYPE 
join table4 tl 
    on t.id = tl.id 
join table5 sa 
where sa.sourcename='GW' and sa.SYSTEM_APPLICATION_SHORT_NAME = 'B'
and  c.TYPE_LIST_ID 
IN (Select typel.TYPE_LIST_ID 
     from table3 typel
     where typel.TYPELIST_TABLE_NAME = 'a' )