Can i alter non-Partitioned table with already loaded data to have dynamic partitions?

48 Views Asked by At

I have tried with using hive command

insert into table partitioned_table_name partition(partition_col) select * from non-Partitioned table ;

1

There are 1 best solutions below

0
Koushik Roy On

Yes, of course you can do it. But you need to select correct sequence of columns while inserting. for example, if your table structure is like this -

create table mytable_patitioned (c1 int, c2 string) partition by c3 int;

Then your insert statement should be like below - partition column should be last column in select statement.

insert into mytable_patitioned partition(c3) select c1,c2,c3 from non_part_table;