hive建表设置如果为null_hive添加分区表字段后,插入数据为null。

首先先让我们来创建一张测试表

hive> create table test(id string)partitioned BY (day string);

OK

Time taken: 0.115 seconds

hive>

从另一张表中的数据 id 查询出来插入当前测试表中

hive> insert into test PARTITION(day='2016-05-06') select id from on_duty_report;

hive> select * from test;

OK

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461662887 2016-05-06

1461684396 2016-05-06

1462418503 2016-05-06

Time taken: 0.043 seconds, Fetched: 12 row(s)

然后我们再来添加一个为 name 的字段

hive> ALTER TABLE test ADD COLUMNS(name string);

OK

Time taken: 0.073 seconds

hive> desc test;

OK

id string

name string

day string

# Partition Information

# col_name data_type comment

day string

Time taken: 0.05 seconds, Fetched: 8 row(s)

从 on_duty_report 表中查询 ID ,shop_id 覆盖 test 分区。

hive> insert OVERWRITE table test PARTITION(day='2016-05-06') select id,shop_id from on_duty_report;

再次查询该表新增字段为 NULL 值。

hive> select * from test;

OK

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461662887 NULL 2016-05-06

1461684396 NULL 2016-05-06

1462418503 NULL 2016-05-06

Time taken: 0.036 seconds, Fetched: 12 row(s)

解决办法:删除该天分区从新插入数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值