您的位置:首页 > 其它

hive向动态分区插入数据

2017-10-11 14:07 288 查看
向一个定义了分区的空表中插入数据,命令如下:

insert overwrite table t_name
partition (par_1)
select t1.field1 as field1, t1.field2 as field2,  t1.field3 as par_1
from (
select * from t3 where par_2=value2) t1
where t1.field1 not in (select field1from t2) ;


结果如下错误:



大概的意思是,在动态分区‘strict’模式下至少需要有一个’strict’列,可以通过设置hive.exec.dynamic.partition.mode=nonstrict来关闭’strict’模式。

至少需要一个’strict’分区列是指至少有一个分区列有至少一个值。

做如下设置:

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=1000;


运行成功。

set hive.exec.dynamic.partition.mode的设置貌似是一次性的,我自己使用的结果是设置完,跑一次插入之后,下一次对新的空动态分区表做插入,又报同样的错误,又设置一次之后,运行成功。

需要注意的是,系统自动将最后partition后的select中的最后n个字段作为n个分区列的值。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hive