File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
main/scala/org/apache/spark/sql
test/scala/org/apache/spark/sql
hive/src/test/scala/org/apache/spark/sql/hive Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,14 @@ class SQLContext(@transient val sparkContext: SparkContext)
188188 }
189189 }
190190
191+ def isCached (tableName : String ): Boolean = {
192+ val relation = catalog.lookupRelation(None , tableName)
193+ EliminateAnalysisOperators (relation) match {
194+ case SparkLogicalPlan (_ : InMemoryColumnarTableScan ) => true
195+ case _ => false
196+ }
197+ }
198+
191199 protected [sql] class SparkPlanner extends SparkStrategies {
192200 val sparkContext = self.sparkContext
193201
Original file line number Diff line number Diff line change @@ -77,11 +77,13 @@ class CachedTableSuite extends QueryTest {
7777 case _ : InMemoryColumnarTableScan => // Found evidence of caching
7878 case _ => fail(s " Table 'testData' should be cached " )
7979 }
80+ assert(TestSQLContext .isCached(" testData" ), " Table 'testData' should be cached" )
8081
8182 TestSQLContext .sql(" UNCACHE TABLE testData" )
8283 TestSQLContext .table(" testData" ).queryExecution.executedPlan match {
8384 case _ : InMemoryColumnarTableScan => fail(s " Table 'testData' should not be cached " )
8485 case _ => // Found evidence of uncaching
8586 }
87+ assert(! TestSQLContext .isCached(" testData" ), " Table 'testData' should not be cached" )
8688 }
8789}
Original file line number Diff line number Diff line change @@ -63,11 +63,13 @@ class CachedTableSuite extends HiveComparisonTest {
6363 case _ : InMemoryColumnarTableScan => // Found evidence of caching
6464 case _ => fail(s " Table 'src' should be cached " )
6565 }
66+ assert(TestHive .isCached(" src" ), " Table 'src' should be cached" )
6667
6768 TestHive .hql(" UNCACHE TABLE src" )
6869 TestHive .table(" src" ).queryExecution.executedPlan match {
6970 case _ : InMemoryColumnarTableScan => fail(s " Table 'src' should not be cached " )
7071 case _ => // Found evidence of uncaching
7172 }
73+ assert(! TestHive .isCached(" src" ), " Table 'src' should not be cached" )
7274 }
7375}
You can’t perform that action at this time.
0 commit comments