@@ -20,13 +20,31 @@ package org.apache.spark.sql
20
20
import org .apache .spark .sql .TestData ._
21
21
import org .apache .spark .sql .columnar .{InMemoryRelation , InMemoryColumnarTableScan }
22
22
import org .apache .spark .sql .test .TestSQLContext
23
+ import org .apache .spark .sql .test .TestSQLContext ._
23
24
24
25
class CachedTableSuite extends QueryTest {
25
26
TestData // Load test tables.
26
27
27
- // NOTE: ALL TESTS ARE IGNORED PENDING SPARK-2264
28
+ test(" SPARK-1669: cacheTable should be idempotent" ) {
29
+ assume(! table(" testData" ).logicalPlan.isInstanceOf [InMemoryRelation ])
28
30
29
- ignore(" read from cached table and uncache" ) {
31
+ cacheTable(" testData" )
32
+ table(" testData" ).queryExecution.analyzed match {
33
+ case _ : InMemoryRelation =>
34
+ case _ =>
35
+ fail(" testData should be cached" )
36
+ }
37
+
38
+ cacheTable(" testData" )
39
+ table(" testData" ).queryExecution.analyzed match {
40
+ case InMemoryRelation (_, _, _ : InMemoryColumnarTableScan ) =>
41
+ fail(" cacheTable is not idempotent" )
42
+
43
+ case _ =>
44
+ }
45
+ }
46
+
47
+ test(" read from cached table and uncache" ) {
30
48
TestSQLContext .cacheTable(" testData" )
31
49
32
50
checkAnswer(
@@ -53,20 +71,20 @@ class CachedTableSuite extends QueryTest {
53
71
}
54
72
}
55
73
56
- ignore (" correct error on uncache of non-cached table" ) {
74
+ test (" correct error on uncache of non-cached table" ) {
57
75
intercept[IllegalArgumentException ] {
58
76
TestSQLContext .uncacheTable(" testData" )
59
77
}
60
78
}
61
79
62
- ignore (" SELECT Star Cached Table" ) {
80
+ test (" SELECT Star Cached Table" ) {
63
81
TestSQLContext .sql(" SELECT * FROM testData" ).registerAsTable(" selectStar" )
64
82
TestSQLContext .cacheTable(" selectStar" )
65
83
TestSQLContext .sql(" SELECT * FROM selectStar WHERE key = 1" ).collect()
66
84
TestSQLContext .uncacheTable(" selectStar" )
67
85
}
68
86
69
- ignore (" Self-join cached" ) {
87
+ test (" Self-join cached" ) {
70
88
val unCachedAnswer =
71
89
TestSQLContext .sql(" SELECT * FROM testData a JOIN testData b ON a.key = b.key" ).collect()
72
90
TestSQLContext .cacheTable(" testData" )
@@ -76,7 +94,7 @@ class CachedTableSuite extends QueryTest {
76
94
TestSQLContext .uncacheTable(" testData" )
77
95
}
78
96
79
- ignore (" 'CACHE TABLE' and 'UNCACHE TABLE' SQL statement" ) {
97
+ test (" 'CACHE TABLE' and 'UNCACHE TABLE' SQL statement" ) {
80
98
TestSQLContext .sql(" CACHE TABLE testData" )
81
99
TestSQLContext .table(" testData" ).queryExecution.executedPlan match {
82
100
case _ : InMemoryColumnarTableScan => // Found evidence of caching
0 commit comments