convert normal column as partition column in hive

2019-08-05 11:46发布

I have a table with 3 columns. now i need to modify one of the column as a partition column. Is there any possibility? If not, how can we add partition to existing table. I used the below syntax: create table t1 (eno int, ename string ) row format delimited fields terminated by '\t'; load data local '/....path/' into table t1; alter table t1 add partition (p1='india');

i am getting errors.........

Any one know how to add partition to existing table......?

Thanks in advance.

2条回答
再贱就再见
2楼-- · 2019-08-05 12:47

I don't think this is directly possible. Hive would have to completely rearrange and split the files in HDFS because adding the partition would impose a new directory structure.

What I suggest you do is simply create a new table with the desired schema and partition, and insert everything from the first into the second.

查看更多
叼着烟拽天下
3楼-- · 2019-08-05 12:51

I think there is no way to convert an existing column of a table to partition. If you want to add a partition in a table use ALTER command as you have already done. If you are dealing with the external table then specify the location field as well. I am not sure whether a partition can be added using ALTER command for managed tables.

查看更多
登录 后发表回答