首页 > 其他 > 详细

Hive带分区列的表更改列类型之坑

时间:2015-09-09 19:31:10      阅读:922      评论:0      收藏:0      [点我收藏+]

常见的一个场景是Hive里面一个带分区的表,原来是int类型的字段,后来发现数据超过了int的最大值,要改成bigint。或者是

bigint要改string或decimal。无论如何,对于带分区的表,要改列类型,有一个坑:

如果使用alter table t change column oldcol newcol bigint,即把int类型的oldcol改为bigint类型的newcol

这个时候,去读数据,应该还是NULL的。

这是因为每个分区Hive还会存一份元数据,于是两种解决方案:

一个是alter table t change column oldcol newcol bigint cascade

一个是alter table t change column oldcol newcol bigint, alter table t partition(...) change column oldcol newcol bigint

参考https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AlterColumn

 

Hive带分区列的表更改列类型之坑

原文:http://www.cnblogs.com/upoo/p/4795573.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!