2
  • inserted data in Hive table with partition column(CL) value as ('CL=18') which stored as /db/tbname/CL=CL%3D18 (invalid partition contains url encoded special character for equal sign).

    • As per hortonworks community , it was mentioned hive stored special characters as url escaped.

      • I tried using escape sequence for equal sign as \x3D(hex) , \u0030 (unicode) but did not work

Ex: alter table tb drop partition (CL='CL\x3D18'); <-- did not work

Can some one help me, am I doing some thing wrong for Equal(=) sign?

Girish501
  • 143
  • 9

1 Answers1

3

Try with alter table id drop partition(cl="cl=18"); (or) by enclosing partition value with single quotes(') also.

i have recreated the scenario on end and able to drop the partitions with special characters without using any hex..etc sequence.

Example:

I have created partition table with cl as partition column stringtype.

hive> alter table t1 add partition(cl="cl=18"); --add the partition to the table
hive> show partitions t1; --list the partititons in the table
+-------------+--+
|  partition  |
+-------------+--+
| cl=cl%3D18  |
+-------------+--+
hive>  alter table t1  drop partition(cl='cl=18'); --drop the partition from the table.
hive>  show partitions t1; 
+------------+--+
| partition  |
+------------+--+
+------------+--+
notNull
  • 30,258
  • 4
  • 35
  • 50
  • 1
    Yea it worked. I tried same thing also earlier but did not work, I might have messed up some thing there. However thanks for your help! – Girish501 Oct 15 '18 at 04:38
  • drop partition name = $%7Bbizdate}, replaced by '${bizdate}' – staticor Dec 28 '18 at 07:36
  • Thank you! I had multiple partitions, one with a `$`, so this worked for me--quoting just the partition with the special character: `drop partition (dt=20210416,hr=00,min='$min',site=newyork)` – Mark Rajcok Apr 17 '21 at 15:42