使用2个表连接的Hive侧视图爆炸

3

检查在Hive中是否有可能实现此功能:

Select a.col1,b.col1
from tableA a join tableB b on a.col1 = b.col1
lateral view explode(numcred) tableA  as creds
where creds.id = 9;

我在文档中找不到答案。简而言之:

我想要在两个表上进行JOIN,并且LATERAL VIEW EXPLODE TABLEA

看起来很简单,但会出现语法问题。

2个回答

9
select  a.col1
       ,b.col1

from   (Select  a.col1

        from    tableA a 
                lateral view explode(numcred) e as creds 

        where   e.creds.id = 9
        ) a

        join    tableB b 

        on      a.col1 = b.col1 

啊哈,糟糕,你赢了,我没看到。 - user1352683

3

我现在不在电脑旁,所以无法测试,但我猜你需要编写一个内部查询。像这样:

SELECT
  a.col1,
  b.col1
FROM (
  SELECT
    dummy.col1
  FROM table_a dummy
  LATERAL VIEW EXPLODE(numcred) tableA as creds
  WHERE 
    creds.id = 9
) a
JOIN tableB b 
ON 
  a.col1 = b.col1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接