【问题标题】:Hive support for subquery in Join condition?Hive 对 Join 条件中的子查询的支持?
【发布时间】:2017-03-23 15:44:26
【问题描述】:

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

我是否需要找到解决方案来使子查询脱离 on 条件?

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)

【问题讨论】:

  • t4? ……
  • @DuduMarkovitz 有 26 个连接,我只放入导致问题的连接,因为它可能会有点疯狂......查询是 192 行的崇高......是的,它可以服务一个独特的目的,每晚运行一次。它是 ETL 替换的集合......还有为什么名称很时髦不想使用供应商逻辑/命名
  • 这不是风格评论。如您所见,t4 未在您的查询中定义。
  • @DuduMarkovitz 是的,很抱歉我把它扔进去以避免混淆。
  • 收集其他表中所有子查询的数据并放入join。如果它适用于您的用例。

标签: sql hadoop hive beeline


【解决方案1】:

我在 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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多