Hive 在这种情况下,当多个表在配置单元中连接时,如何使用横向视图?

Hive 在这种情况下,当多个表在配置单元中连接时,如何使用横向视图?,hive,hiveql,Hive,Hiveql,我有这张桌子 table 1 id, array<string>(place_id) 1, [1 ,2] 2, [2, 3] table 2 (Metadata) id, some_meta table 3 (Places) 1, Name1 2, Name2 3, Name3 我现在被困在FROM子查询中 FROM table1 t1 JOIN table2 t2 ON t1.id = t2.id 这就是我目前所知道的。如何将t1.place\u id与table3

我有这张桌子

table 1
id, array<string>(place_id)
1, [1 ,2]
2, [2, 3]

table 2 (Metadata)
id, some_meta

table 3 (Places)
1, Name1
2, Name2
3, Name3
我现在被困在FROM子查询中

FROM
  table1 t1
  JOIN table2 t2 ON t1.id = t2.id

这就是我目前所知道的。如何将
t1.place\u id
table3
连接以获取地点名称?我对HIVE不太了解。

在阵列上使用
侧面视图
分解
,并使用
连接
的值

select t1.id,concat_ws(',',collect_list(t3.places)),t2.some_meta
from (select id,places
      from table1
      lateral view explode(place_id) tbl as places
     ) t1
join t2 on t1.id=t2.id
join t3 on t1.places=t3.id
group by t1.id,t2.some_meta
select t1.id,concat_ws(',',collect_list(t3.places)),t2.some_meta
from (select id,places
      from table1
      lateral view explode(place_id) tbl as places
     ) t1
join t2 on t1.id=t2.id
join t3 on t1.places=t3.id
group by t1.id,t2.some_meta