Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

Hive drop partition issue error in metastore query

New Contributor

I'm getting a curious error when i'm trying to drop partitions from a managed table:

hive> ALTER TABLE table_name DROP PARTITION (date_val < '2017-01-28');

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Exception thrown when executing query : SELECT "A0"."PART_NAME","A0"."PART_NAME" AS "NUCORDER0" FROM "PARTITIONS" "A0" LEFT OUTER JOIN "TBLS" "B0" ON "A0"."TBL_ID" = "B0"."TBL_ID" LEFT OUTER JOIN "DBS" "C0" ON "B0"."DB_ID" = "C0"."DB_ID" WHERE "C0"."NAME" = ? AND "B0"."TBL_NAME" = ? ORDER BY "NUCORDER0"

As some basic troubleshooting I've tried:

msck repair table <table_name> (STILL RUNNING)

I can run a manual query against the metastore that WORKS if I replace the "?" in the above error with real values

Super duper confused, any help/suggestions would be great


New Contributor

Fixed this by discovering my date_val column had the '__HIVE_DEFAULT_PARTITION__' and then was failing on this alter because the value didn't work with the column datatype (DATE vs STRING)

I got around this by changing the column to string, drop the partition for the default and then change it back to date. Got some pointers from here: