Hive 1.1.0 Alter table partition type from int to string

后端 未结 2 898
猫巷女王i
猫巷女王i 2021-01-05 06:39

I have a table which has a partition of type int but which I want to convert to string. However, I can\'t figure out how to do this.

The table description is:

<
2条回答
  •  抹茶落季
    2021-01-05 07:15

    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.

提交回复
热议问题