diff options
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala | 2 | ||||
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala index 95d73c1711..a66af602a1 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala @@ -501,7 +501,7 @@ class SchemaRDD( } override def unpersist(blocking: Boolean): this.type = { - sqlContext.uncacheQuery(this, blocking) + sqlContext.tryUncacheQuery(this, blocking) this } } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala index 042210176a..cfc037caff 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala @@ -49,6 +49,20 @@ class CachedTableSuite extends QueryTest { uncacheTable("tempTable") } + test("unpersist an uncached table will not raise exception") { + assert(None == lookupCachedData(testData)) + testData.unpersist(true) + assert(None == lookupCachedData(testData)) + testData.unpersist(false) + assert(None == lookupCachedData(testData)) + testData.persist() + assert(None != lookupCachedData(testData)) + testData.unpersist(true) + assert(None == lookupCachedData(testData)) + testData.unpersist(false) + assert(None == lookupCachedData(testData)) + } + test("cache table as select") { sql("CACHE TABLE tempTable AS SELECT key FROM testData") assertCached(sql("SELECT COUNT(*) FROM tempTable")) |