【问题标题】:create a new hive table with values from two hive tables使用来自两个配置单元表的值创建一个新配置单元表
【发布时间】:2017-05-30 14:11:45
【问题描述】:

我想创建一个包含 3 列的配置单元表。比方说,id,average,incharge。 id 和 average 的值在表“first”中。而对于 incharge 列,我需要对表“秒”执行查询。我试过了,但失败了

create table third(
 ID INT,
 AVERAGE INT,
 INCHARGE STRING
 )
from first f
insert into table third select
f.id,
f.average,
from ( select second.incharge where second.k_id == f.id limit 1)

任何线索都会很有帮助

【问题讨论】:

    标签: hiveql


    【解决方案1】:
    FROM (
    SELECT
        f.id ,
        f.average
    FROM
        FIRST f ) x JOIN
       (
    SELECT
        s.incharge ,
        s.sid
    FROM
        second s ) y ON y.sid = x.id
    INSERT
    OVERWRITE TABLE third
    SELECT
    x.id ,
    x.average ,
    y.incharge
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 2017-08-05
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 2016-02-11
    相关资源
    最近更新 更多