Hive支持Join条件中的子查询?

时间:2017-03-23 15:44:27

标签: sql hadoop hive beeline

错误:编译语句时出错:FAILED:0个孩子遇到SemanticException(state = 42000,code = 40000)

我是否需要找到一个解决方案才能使子查询脱离开启状态?

select
-- a bunch of stuff min,max,sum and case statements
from tbl0 t0
inner join tbl4  t4  on (t4.aKey = t0.aKey)  
left outer join tbl1  t1  on (t0.col0 = t1.col0 and t1.someKey in (select t3.aKey from tbl3 t3 where t3.someCode in ('A1','A2','A3')))
where
not(t4.aCode in ('string1' , 'strin2' , 'string3' , 'string4') and t1.someKey is null) and not (t4.bCode in ('string1' , 'string2') and t1.someCol = 0)

1 个答案:

答案 0 :(得分:0)

我在Hive 1.1中也遇到了这个错误。

我认为Ashish Singh可能有最好的建议:通过移动该表定义中的IN(SELECT ...)语句将tbl1更改为子查询。

您的查询将成为:

select -- a bunch of stuff min,max,sum and case statements from tbl0 t0 inner join tbl4 t4 on (t4.aKey = t0.aKey) left outer join (SELECT col0 FROM tbl1 WHERE somekey IN (SELECT t3.aKey FROM tbl3 t3 WHERE t3.someCode in ('A1','A2','A3'))) t1 on (t0.col0 = t1.col0) where not(t4.aCode in ('string1' , 'strin2' , 'string3' , 'string4') and t1.someKey is null) and not (t4.bCode in ('string1' , 'string2') and t1.someCol = 0)