从两张桌子中选择并使用侧视蜂巢

时间:2018-01-24 16:41:30

标签: sql hadoop hive

我正在尝试从Hive中的两个表中进行选择,但它似乎给了我一个错误

select b.item item1, street.id as street_id, street.name as street_name, 
c.color as color_id, 'cities' as city  
from mytable.first b, mytable.second c 
LATERAL VIEW EXPLODE(b.cities) citiestbl as street

这给了我一个

  

编译语句时出错:FAILED:SemanticException [错误10085]:第1行:120不支持使用LATERAL VIEW加入' c'

1 个答案:

答案 0 :(得分:0)

您正在查询中的第一个和第二个表之间执行cross join并使用lateral view。如错误消息所示,不支持join lateral view

不确定您是否需要交叉连接,但重新将查询重写为

select bc.item as item1, citiestbl.street, bc.color as color_id, bc.cities as city  
from (select b.item,c.color,b.cities 
      from mytable.first b 
      cross join mytable.second c) bc 
LATERAL VIEW EXPLODE(bc.cities) citiestbl as street 
--Note that citiestbl is a table alias and street is the column-alias for the exploded column
--Only the exploded column can be referred to in the select, which is street in this case
相关问题