Hive 动态分区 [英] Hive dynamic partitioning

查看:34
本文介绍了Hive 动态分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用动态分区创建分区表,但我遇到了一个问题.我在 Hortonworks Sandbox 2.0 上运行 Hive 0.12.

I'm trying to create a partitioned table using dynamic partitioning, but i'm facing an issue. I'm running Hive 0.12 on Hortonworks Sandbox 2.0.

set hive.exec.dynamic.partition=true;
INSERT OVERWRITE TABLE demo_tab PARTITION (land)
SELECT stadt, geograph_breite, id, t.country
FROM demo_stg t;

但是它不起作用..我收到一个错误.

however it does not work.. I'm getting an Error.

这是创建表的查询demo_stg:

create table demo_stg
(
    country STRING,
    stadt STRING,
    geograph_breite FLOAT,
    id INT
    )
ROW FORMAT DELIMITED FIELDS TERMINATED BY "73";

demo_tab:

CREATE TABLE demo_tab 
(
    stadt STRING,
    geograph_breite FLOAT,
    id INT
)
PARTITIONED BY (land STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY "73";

  • demo_stg 也填充了数据,所以它不是空的.
    • The table demo_stg is also filled with data, so it's not empty.
    • 感谢您的帮助:)

      推荐答案

      您需要修改您的选择:

      set hive.exec.dynamic.partition=true;
      INSERT OVERWRITE TABLE demo_tab PARTITION (land)
      SELECT stadt, geograph_breite, id, t.country
      FROM demo_stg t;
      

      我不确定您要对演示中的哪一列执行分区,或者演示中的哪一列对应于土地.但是无论列是什么,它都应该作为 select 中的最后一列出现,比如您的演示表列名称是 id,因此您的 select 应该写为:

      I am not sure to which column on your demo staging you want to perform partitioning or which column in demo corresponds to land. But whatever is the column it should be present as the last column in select say your demo table column name is id so your select should be written as:

      INSERT OVERWRITE TABLE demo_tab PARTITION (land)
      SELECT stadt, geograph_breite, id, t.country,t.id as land
      FROM demo_stg t;
      

      我认为这应该可行.

      这篇关于Hive 动态分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆