Skip to content

Commit

Permalink
Catch all exception when we try to uncache a query.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Jan 16, 2015
1 parent e8422c5 commit 6b69ed1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 comments on commit 6b69ed1

Please sign in to comment.