Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop 蜂巢动态分区_Hadoop_Hive_Hiveql - Fatal编程技术网

Hadoop 蜂巢动态分区

Hadoop 蜂巢动态分区,hadoop,hive,hiveql,Hadoop,Hive,Hiveql,我试图使用动态分区创建一个分区表,但我面临一个问题。我正在Hortonworks沙盒2.0上运行Hive0.12 set hive.exec.dynamic.partition=true; INSERT OVERWRITE TABLE demo_tab PARTITION (land) SELECT stadt, geograph_breite, id, t.country FROM demo_stg t; 但是它不起作用。。我有个错误 以下是创建表的查询demo\u stg: create

我试图使用动态分区创建一个分区表,但我面临一个问题。我正在Hortonworks沙盒2.0上运行Hive0.12

set hive.exec.dynamic.partition=true;
INSERT OVERWRITE TABLE demo_tab PARTITION (land)
SELECT stadt, geograph_breite, id, t.country
FROM demo_stg t;
但是它不起作用。。我有个错误

以下是创建表的查询demo\u stg

create table demo_stg
(
    country STRING,
    stadt STRING,
    geograph_breite FLOAT,
    id INT
    )
ROW FORMAT DELIMITED FIELDS TERMINATED BY "\073";
CREATE TABLE demo_tab 
(
    stadt STRING,
    geograph_breite FLOAT,
    id INT
)
PARTITIONED BY (land STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY "\073";
和演示选项卡:

create table demo_stg
(
    country STRING,
    stadt STRING,
    geograph_breite FLOAT,
    id INT
    )
ROW FORMAT DELIMITED FIELDS TERMINATED BY "\073";
CREATE TABLE demo_tab 
(
    stadt STRING,
    geograph_breite FLOAT,
    id INT
)
PARTITIONED BY (land STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY "\073";
  • demo\u stg也充满了数据,因此它不是空的

谢谢您的帮助:)

您需要修改您的选择:

set hive.exec.dynamic.partition=true;
INSERT OVERWRITE TABLE demo_tab PARTITION (land)
SELECT stadt, geograph_breite, id, t.country
FROM demo_stg t;
我不确定您想在演示阶段的哪个列上执行分区,或者演示中的哪个列对应于land。但是,无论列是什么,它都应该作为select中的最后一列出现,比如说演示表列名是id,所以select应该写为:

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

我认为这应该是可行的。

分区列需要是select查询中的最后一列

除了将分区设置为true之外,还需要将mode设置为nonstrict:

set hive.exec.dynamic.partition.mode=nonstrict

出现了什么错误?请尝试添加SET-hive.exec.dynamic.partition.mode=nonstrict;如果我尝试运行“SET-hive.exec.dynamic.partition.mode=nonstrict;”,我会得到一个错误。我收到的每个错误消息都是这样的:“执行配置单元查询时出错:未知异常。”感谢您的帮助:)选择:“插入覆盖表demo_选项卡分区(land)select statt,geograph_breite,id,t.country,t.id as land FROM demo_stg t;”有效!我很高兴它成功了。欢迎光临。此外,如果要对多个列进行分区,则select应该按照insert语句之后在partition子句中指定的顺序包含多个as。几天前,我在doc的同一个@上写了一篇博客:
动态分区列必须在SELECT语句的列中最后指定,并且必须按照它们在partition()子句中出现的相同顺序指定