2016-06-01 36 views
2

我有一个原始外部表具有四个columns- 表1:蜂房插入覆盖到动态分区外部表从原始外部表失败,零指示字例外,

创建外部表external_partitioned_rawtable
(age_bucket 字符串,字符串country_destination,性别 串,population_in_thousandsyear INT)
行格式分隔 字段由 '\ T'
线用 '\ n' 位置 '/用户/ HadoopUser /蜂巢'

终止终止

我希望有一个外部表与来自Country_destination和gender.Table -2分区

创建外部表external_partitioned
(age_bucket 字符串,population_in_thousandsyear INT)
分配由 (country_destination字符串,性别字串)
行格式分隔 以'\ t'结尾的字段
以'\ n'结尾的行;

插入覆盖与空指针失败exception-

insert overwrite table external_partitioned partition(country_destination,gender) <br> 
select (age_bucket,population_in_thousandsyear,country_destination,gender) <br> 
from external_partitioned_rawtable; 

失败:NullPointerException异常空

回答

1

对于动态分区插入,执行INSERT语句之前,你必须执行蜂房的两个属性:

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

然后执行插入语句(我已修改)

insert overwrite table external_partitioned partition(country_destination,gender) 
select age_bucket,population_in_thousandsyear,country_destination,gender 
from external_partitioned_rawtable; 

我希望这对你有帮助!

+0

非常感谢,我们为什么要使用非严格模式? – Barath

+0

默认情况下,它被设置为严格模式。在严格模式下不允许动态分区。那么你必须设置非严格 – Farooque