-1

I am trying to use

alter table drop if exists partition

statement to delete data in Hive table.

What would happen if .Trash folder is full? Will the alter table statement just fail silently? What's the workaround?

Yogendra
  • 1,208
  • 5
  • 18
  • 38
dwong
  • 103
  • 5
  • 14
  • Does this answer your question? [How to delete and update a record in Hive](https://stackoverflow.com/questions/17810537/how-to-delete-and-update-a-record-in-hive) – Yogendra Aug 11 '23 at 05:05
  • i'm using sparksql, not hive – dwong Aug 11 '23 at 05:12
  • Does this answer your question? [sparksql drop hive table](https://stackoverflow.com/questions/39787792/sparksql-drop-hive-table) – Bahubali Aug 11 '23 at 05:25
  • @Bahubali i'm trying to drop partitions of a hive table, not dropping the entire table. – dwong Aug 11 '23 at 05:33

2 Answers2

1

If the hive table is external then the drop partition will only remove the reference in the metastore, leaving the filesystem data intact.

If it's a managed table, then both will be removed. When purge keyword is added it will skip the .trash folder

ALTER TABLE table_identifier DROP [ IF EXISTS ] partition_spec [PURGE]

Now if .trash folder gets full your cluster will be in unhealthy state. Not sure if the deletion process will fail thought.

parisni
  • 920
  • 7
  • 20
0

Try this

DROP TABLE IF EXIST partition

Bahubali
  • 424
  • 1
  • 3
  • 18