Hive 1.1.0 Alter table partition type from int to string

浪子不回头ぞ 提交于 2019-12-01 04:43:12
sokhaty

A bit of digging revealed that there was a hive JIRA to have a command exactly for updating partition column data type (https://issues.apache.org/jira/browse/HIVE-3672)

alter table {table_name} partition column ({column_name} {column_type});

According to JIRA the command was implemented, but it's apparent that it was never documented on Hive Wiki.

I used it on my Hive 0.14 system and it worked as expected.

I think yo should redefine the table's schema and redefine that your partition value is not gonna be a integer anymore and this is now gonna be a string type.

What I recommend you to do is:

  1. Make your table external (in case you define this as a non-external table). In this case you can drop the table without removing the data in the directories.
  2. Drop the table.
  3. Create again the table with the new schema (Partition value as a string).

The steps above, physically (structure folders) is not gonna make any difference with the structure that you already had. The difference is gonna be in the Hive metastore, specifically in the "virtual column" created when you make partitions.

Also, now instead making queries like: part_col = 1, now you are gonna be able to make queries like: part_col = '1'.

Try this and tell me how this goes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!