配置单元动态分区 [英] Hive dynamic partitioning

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

问题描述

我正在尝试使用动态分区创建分区表,但是我遇到了一个问题.我正在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 "\073";

demo_tab :

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

  • 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,因此您的选择应写为:

      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;
      

      我认为这应该可行.

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

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