GitHub user andrewor14 opened a pull request:
https://github.com/apache/spark/pull/13315
[SPARK-15538][SQL] Fix TRUNCATE TABLE for datasource tables
## What changes were proposed in this pull request?
Before:
```
scala> sql("CREATE TABLE boxes (length INT, height INT, width INT) USING
parquet")
scala> (1 to 3).map { i => (i, i * 2, i * 3) }.toDF("height", "length",
"width").write.insertInto("boxes")
scala> spark.table("boxes").show()
+------+------+-----+
|length|height|width|
+------+------+-----+
| 1| 2| 3|
| 2| 4| 6|
| 3| 6| 9|
+------+------+-----+
scala> sql("TRUNCATE TABLE boxes")
scala> spark.table("boxes").show() // FileNotFound exception
```
After:
```
scala> sql("TRUNCATE TABLE boxes")
scala> spark.table("boxes").show()
+------+------+-----+
|length|height|width|
+------+------+-----+
+------+------+-----+
```
## How was this patch tested?
`DDLSuite`
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/andrewor14/spark truncate-table
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13315.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #13315
----
commit f02b5912e814b9500b1d66b734ad37698d93876f
Author: Andrew Or <[email protected]>
Date: 2016-05-26T00:42:49Z
Support TRUNCATE TABLE for datasource tables
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]