i have created a non partitioned table and load data into the table,now i want to add a PARTITION
on the basis of department into that table,can I do this?
If I do:
ALTER TABLE Student ADD PARTITION (dept='CSE') location '/test';
It gives me error:
FAILED: SemanticException table is not partitioned but partition spec exists: {dept=CSE}
please help. Thanks
First create a table in such a way so that you don't have partition column in the table.
create external table Student(col1 string, col2 string) partitioned by (dept string) location 'ANY_RANDOM_LOCATION';
Once you are done with the creation of the table then alter the table to add the partition department wise like this :
alter table Student add partition(dept ='cse') location '/test';
I hope this will help.