Repository: spark
Updated Branches:
  refs/heads/master cd5da4285 -> 2604bc35d


[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 <yh...@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.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2604bc35
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2604bc35
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2604bc35

Branch: refs/heads/master
Commit: 2604bc35d7205866e2b6c2d80f4b2ad715177642
Parents: cd5da42
Author: Yin Huai <yh...@databricks.com>
Authored: Mon Jan 19 10:45:29 2015 -0800
Committer: Michael Armbrust <mich...@databricks.com>
Committed: Mon Jan 19 10:45:29 2015 -0800

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/execution/commands.scala |  5 +++++
 .../spark/sql/hive/MetastoreDataSourcesSuite.scala     | 13 +++++++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2604bc35/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala
----------------------------------------------------------------------
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 cf72345..91f9da3 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")

http://git-wip-us.apache.org/repos/asf/spark/blob/2604bc35/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
----------------------------------------------------------------------
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 8ff833e..53d8aa7 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)
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to