Skip to content
Snippets Groups Projects
Commit 2604bc35 authored by Yin Huai's avatar Yin Huai Committed by Michael Armbrust
Browse files

[SPARK-5286][SQL] Fail to drop an invalid table when using the data source API

JIRA: https://issues.apache.org/jira/browse/SPARK-5286

Author: Yin Huai <yhuai@databricks.com>

Closes #4076 from yhuai/SPARK-5286 and squashes the following commits:

6b69ed1 [Yin Huai] Catch all exception when we try to uncache a query.
parent cd5da428
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,12 @@ case class DropTable(
try {
hiveContext.tryUncacheQuery(hiveContext.table(tableName))
} catch {
// This table's metadata is not in
case _: org.apache.hadoop.hive.ql.metadata.InvalidTableException =>
// Other exceptions can be caused by users providing wrong parameters in OPTIONS
// (e.g. invalid paths). We catch it and log a warning message.
// Users should be able to drop such kinds of tables regardless if there is an exception.
case e: Exception => log.warn(s"${e.getMessage}")
}
hiveContext.invalidateTable(tableName)
hiveContext.runSqlHive(s"DROP TABLE $ifExistsClause$tableName")
......
......@@ -242,4 +242,17 @@ class MetastoreDataSourcesSuite extends QueryTest with BeforeAndAfterEach {
assert(expectedSchema == table("jsonTable").schema)
}
test("SPARK-5286 Fail to drop an invalid table when using the data source API") {
sql(
s"""
|CREATE TABLE jsonTable
|USING org.apache.spark.sql.json.DefaultSource
|OPTIONS (
| path 'it is not a path at all!'
|)
""".stripMargin)
sql("DROP TABLE jsonTable").collect.foreach(println)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment