17
17
18
18
package org .apache .spark .sql .hive
19
19
20
+ import org .scalatest .BeforeAndAfterAll
21
+
20
22
import scala .reflect .ClassTag
21
23
22
24
@@ -26,7 +28,16 @@ import org.apache.spark.sql.execution.{BroadcastHashJoin, ShuffledHashJoin}
26
28
import org .apache .spark .sql .hive .test .TestHive
27
29
import org .apache .spark .sql .hive .test .TestHive ._
28
30
29
- class StatisticsSuite extends QueryTest {
31
+ class StatisticsSuite extends QueryTest with BeforeAndAfterAll {
32
+
33
+ override def beforeAll () = {
34
+ // HACK: Cached tables do not currently preserve statistics...
35
+ TestHive .cacheTables = false
36
+ }
37
+
38
+ override def afterAll () = {
39
+ TestHive .cacheTables = true
40
+ }
30
41
31
42
test(" parse analyze commands" ) {
32
43
def assertAnalyzeCommand (analyzeCommand : String , c : Class [_]) {
@@ -126,7 +137,7 @@ class StatisticsSuite extends QueryTest {
126
137
val sizes = rdd.queryExecution.analyzed.collect { case mr : MetastoreRelation =>
127
138
mr.statistics.sizeInBytes
128
139
}
129
- assert(sizes.size === 1 )
140
+ assert(sizes.size === 1 , s " Size wrong for: \n ${rdd.queryExecution} " )
130
141
assert(sizes(0 ).equals(BigInt (5812 )),
131
142
s " expected exact size 5812 for test table 'src', got: ${sizes(0 )}" )
132
143
}
@@ -147,7 +158,7 @@ class StatisticsSuite extends QueryTest {
147
158
case r if ct.runtimeClass.isAssignableFrom(r.getClass) => r.statistics.sizeInBytes
148
159
}
149
160
assert(sizes.size === 2 && sizes(0 ) <= autoBroadcastJoinThreshold,
150
- s " query should contain two relations, each of which has size smaller than autoConvertSize " )
161
+ s " query should contain two relations, each of which has size smaller than autoConvertSize instead ${rdd.queryExecution} " )
151
162
152
163
// Using `sparkPlan` because for relevant patterns in HashJoin to be
153
164
// matched, other strategies need to be applied.
0 commit comments