Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Can't change Hive partition with leading zeros

Can't change Hive partition with leading zeros

Contributor

I have moved the location of a Hive table (in HDP 2.6.3) and it turns out I have to change the locations of the partitions one by one. So I was doing allright changing the locations of partitions of october, november and december. But I can't seem to get a grasp on partitions with any month that starts with a leading zero.

hive> ALTER TABLE emtotal PARTITION (year=2017,month=12) SET LOCATION "hdfs://dataMaster/data/test/sensitive/em/year=2017/month=12";
OK
Time taken: 0.766 seconds
hive> ALTER TABLE emtotal PARTITION (year=2017,month=01) SET LOCATION "hdfs://dataMaster/data/test/sensitive/em/year=2017/month=01";
FAILED: SemanticException [Error 10006]: Partition not found {year=2017, month=1

So I tried all kinds of combinations of quotes. This one is often advised:

ALTER TABLE emtotal PARTITION (year=2017,month='01') SET LOCATION "hdfs://dataMaster/data/test/sensitive/em/year=2017/month=01";
FAILED: SemanticException [Error 10006]: Partition not found {year=2017, month=1}

I've tried the following combinations:

('year=2017,month=09')
(year=2017,month=\'09\')
(year='2017',month='09')
("year=2017,month=09")
(year=2017,month="09")
(`year=2017,month=09`)

All failed.

Any ideas?

2 REPLIES 2

Re: Can't change Hive partition with leading zeros

@Marcel-Jan Krijgsman,

Found a similar thread. Hope this helps

Re: Can't change Hive partition with leading zeros

Contributor

@Aditya Sirna

So this basically says: "change the type of your partition keys". I'll have to check if that is possible with the application.

Still weird that you can't do anything with your individual partitions because you choose the wrong type. There must be some way to get a handle on them.

In the meantime I've solved the issue for now by dropping and creating the table.