从两个表中选择并使用横向视图配置单元

nzrxty8p  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(366)

我试图从配置单元中的两个表中进行选择,但似乎给了我一个错误

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

这给了我一个机会
编译语句时出错:失败:semanticexception[error 10085]:不支持行1:120与横向视图的联接“c”

4ioopgfo

4ioopgfo1#

您正在执行 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

相关问题