Reputation: 9671
I was expecting the same behavior of truncate in SQL and HIVE. But its different. I want to confirm if I am perceiving it wrongly
1) In SQL, The following command drop table and create again. All partitions are dropped if exist
mysql> truncate table t1;
2) In HIVE, The following command just delete the data from the table. It do not drop the existing partitions. We need to drop it manually.
hive> truncate table t1;
I found one more issue, If we add column to a partitioned table with altering it. Then there will be a problem in insert overwrite data to the table. Work around found was to drop all the existing partitions on the table.
Is it a issue in HIVE(version 0.13)? What are the other difference in using truncate for HIVE and SQL?
Upvotes: 0
Views: 6600
Reputation: 790
In HIVE truncate table
will Removes all rows from a table or partition(s).
The partitions won't get remove.We have to manually drop those partitions.
Currently target table should be native/managed table or exception will be thrown.
Upvotes: 1