Here are some sample scripts and their effects.
Let's say we have a table SOME_TABLE with three fields, A, B, and C, and two partition fields, YEAR, and MONTH.
Let's assume that we want to delete the data in the table but not the structure of the table.
1. No partition specifications
If we run
INSERT OVERWRITE TABLE SOME_TABLE
PARTITION
(
YEAR
,MONTH
)
SELECT A,B,C,YEAR,MONTH
FROM SOME_TABLE
WHERE FALSE
then the query executes but the data stays there.
2. Partial partition specifications
If we run
INSERT OVERWRITE TABLE SOME_TABLE
PARTITION
(
YEAR=2018
,MONTH
)
SELECT A,B,C,MONTH
FROM SOME_TABLE
WHERE FALSE
then the same happens: the data stays there.
3. Full partition specifications
If we run
INSERT OVERWRITE TABLE SOME_TABLE
PARTITION
(
YEAR=2018
,MONTH=11
)
SELECT A,B,C
FROM SOME_TABLE
WHERE FALSE
only then will the data be erased, and only for the given year and month. The data in other partitions doesn't get deleted.
Note that no partitions have been dropped, and a SHOW PARTITIONS SOME_TABLE returns all partitions, including those that existed before running an INSERT OVERWRITE.
Side note:
I'd be curious to know if there is a way to delete all existing data, but keep the table structure. DROP TABLE would drop the structure. ALTER TABLE ... DROP PARTITION would only delete the targeted partitions, so we would have to know in advance what range of values each partition field takes. In this example, we could do
ALTER TABLE SOME_TABLE DROP PARTITION(year>=0,month>0) PURGE;
but it still seems too complex a solution.