我试图使用动态分区创建分区表,但我面临一个问题。我正在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";
demo\u stg表也充满了数据,所以它不是空的。
感谢您的帮助:)
2条答案
按热度按时间nzk0hqpo1#
您需要修改您的选择:
我不确定您想在演示阶段的哪个列执行分区,或者演示阶段的哪个列对应于land。但是无论列是什么,它都应该作为select中的最后一列出现,比如说您的演示表列名是id,所以您的select应该写为:
我想这应该管用。
3okqufwl2#
分区列必须是select查询中的最后一列。
除将分区设置为true外,还需要将mode设置为nonstrict: