4

我有一个包含四列的原始外部表 - 表 1:

创建外部表 external_partitioned_rawtable
(age_bucket String,country_destination String,gender string,population_in_thousandsyear int)
行格式分隔字段以 '\t'
终止 行以 '\n' 位置 '/user/HadoopUser/hive' 终止

我想要一个带有 Country_destination 和 gender.Table -2 分区的外部表

创建外部表 external_partitioned
(age_bucket String,population_in_thousandsyear int)
分区 (country_destination String,gender String)
行格式分隔字段以 '\t'
结束 行以 '\n' 结束;

插入覆盖因空指针异常而失败-

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 null

4

1 回答 1

2

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

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;

我希望这对你有帮助!!!

于 2016-06-01T07:06:08.183 回答