【问题标题】:Two different table counts insert into Hive Table两个不同的表计数插入 Hive 表
【发布时间】:2019-07-07 13:01:49
【问题描述】:

我需要将来自两个不同表数的数据插入 hive 表中。

例如,假设我有一个表 sample 具有字段 counter1counter2

现在我还有另外两张桌子test1test2

我需要插入sample.counter1 as select count(*) from test1sample.counter2 as select count(*) from test2

如果最终表格有一列,则它可以工作:

insert into table sample select count(*) from test1

现在我需要插入两列。

有什么建议吗?

【问题讨论】:

    标签: sql hadoop hive hiveql


    【解决方案1】:

    这是你要找的吗?

    insert into sample.counter1 (counter1, counter2)
        select t1.cnt, t2.cnt
        from (select count(*) as cnt from test1) t1 cross join
             (select count(*) as cnt from test2) t2;
    

    【讨论】:

    • 你好@Gordon Linoff,正在工作!,知道我是否还有另一个字符串列,查询会是什么?
    • @SatishKaruturi 。 . .您可以向SELECT 添加一个常量值。如果这不能回答您的问题,您应该提出一个新的问题,并提供适当的样本数据和所需的结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多