diff options
author | Yin Huai <yhuai@databricks.com> | 2015-01-19 10:45:29 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-01-19 10:45:29 -0800 |
commit | 2604bc35d7205866e2b6c2d80f4b2ad715177642 (patch) | |
tree | 0e72b07348ee8e25be04a802de459a0c2988b6af /sql | |
parent | cd5da428537b8dfa0bbb9592d344316c26d8f625 (diff) | |
download | spark-2604bc35d7205866e2b6c2d80f4b2ad715177642.tar.gz spark-2604bc35d7205866e2b6c2d80f4b2ad715177642.tar.bz2 spark-2604bc35d7205866e2b6c2d80f4b2ad715177642.zip |
[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.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala | 5 | ||||
-rw-r--r-- | sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala index cf72345efa..91f9da35ab 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala @@ -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") diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala index 8ff833e0d6..53d8aa7739 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala @@ -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) + } } |