蜂巢侧视图爆炸,有2个桌子连接

时间:2017-07-27 03:08:27

标签: hive lateral-join

检查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;

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

我想加入两张桌子和LATERAL VIEW EXPLODE TABLEA

看起来很简单,但会引发语法问题。

2 个答案:

答案 0 :(得分:6)

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 

答案 1 :(得分:1)

现在不在我的电脑上,所以没办法测试这个,但我猜你是不得不写一个内部查询。像这样:

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