[SPARK-15538][SPARK-15536][SQL] Truncate table fixes round 2#13315
[SPARK-15538][SPARK-15536][SQL] Truncate table fixes round 2#13315andrewor14 wants to merge 6 commits intoapache:masterfrom
Conversation
|
Test build #59320 has finished for PR 13315 at commit
|
|
Test build #59323 has finished for PR 13315 at commit
|
|
@andrewor14 |
|
@sureshthalamati what behavior did you expect? I would think that truncating a partitioned table without specifying the specs should just delete data from all partitions, which is what this patch does. |
|
{{sql("truncate table emp16") }} should delete all partitions, right? |
| val locations = if (partitionSpec.isDefined) { | ||
| catalog.listPartitions(tableName, partitionSpec).map(_.storage.locationUri) | ||
| if (table.partitionColumnNames.nonEmpty) { | ||
| catalog.listPartitions(tableName).map(_.storage.locationUri) |
There was a problem hiding this comment.
This is for hive table, right?
|
@andrewor14 The behavior you mentioned is the one I was expecting also. For some reason it does not work in my env. I was trying for a spark-shell . What catalog are you using ? Probably I just need to try with a clean build. |
|
@andrewor14 After I cleaned up the old metastore_db , truncate worked as expected. Thanks |
|
Test build #59401 has finished for PR 13315 at commit
|
|
@andrewor14 one minor thing I noticed when I looked at the table data directories; In the case of regular tables truncate keeps the partition directories, for data source table partition directories also deleted. It may be ok , thought I will mention it incase if we want to be consistent |
|
I tested partitioned data source tables too. If you add data back then the partitions will be created again. I think that's OK. |
|
lgtm |
1 similar comment
|
lgtm |
|
LGTM |
|
Test build #59417 has finished for PR 13315 at commit
|
|
Test build #59434 has finished for PR 13315 at commit
|
|
Thanks for all the LGTMs. I'm going to merge this into master 2.0. |
## What changes were proposed in this pull request? Two more changes: (1) Fix truncate table for data source tables (only for cases without `PARTITION`) (2) Disallow truncating external tables or views ## How was this patch tested? `DDLSuite` Author: Andrew Or <andrew@databricks.com> Closes #13315 from andrewor14/truncate-table.
What changes were proposed in this pull request?
Two more changes:
(1) Fix truncate table for data source tables (only for cases without
PARTITION)(2) Disallow truncating external tables or views
How was this patch tested?
DDLSuite