【问题标题】:selecting from two tables and using lateral view hive从两个表中选择并使用横向视图配置单元
【发布时间】:2018-07-03 19:08:12
【问题描述】:

我正在尝试从 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 [Error 10085]: Line 1:120 JOIN with a LATERAL VIEW is not supported 'c'

【问题讨论】:

  • 如果语法不受支持,那么你就不能做你想做的事。

标签: sql hadoop hive


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2011-04-03
    相关资源
    最近更新 更多