Skip to content

Commit 2d0e168

Browse files
marmbrusliancheng
authored andcommitted
Run Hive tests in-memory too.
1 parent 6360723 commit 2d0e168

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/TestHive.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class TestHiveContext(sc: SparkContext) extends LocalHiveContext(sc) {
257257

258258
private val loadedTables = new collection.mutable.HashSet[String]
259259

260+
var cacheTables: Boolean = false
260261
def loadTestTable(name: String) {
261262
if (!(loadedTables contains name)) {
262263
// Marks the table as loaded first to prevent infite mutually recursive table loading.
@@ -265,6 +266,9 @@ class TestHiveContext(sc: SparkContext) extends LocalHiveContext(sc) {
265266
val createCmds =
266267
testTables.get(name).map(_.commands).getOrElse(sys.error(s"Unknown test table $name"))
267268
createCmds.foreach(_())
269+
270+
if (cacheTables)
271+
cacheTable(name)
268272
}
269273
}
270274

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCompatibilitySuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
package org.apache.spark.sql.hive.execution
1919

2020
import org.apache.spark.sql.hive.TestHive
21+
import org.scalatest.BeforeAndAfter
22+
23+
class HiveInMemoryCompatibilitySuite extends HiveCompatibilitySuite with BeforeAndAfter {
24+
override def beforeAll() {
25+
TestHive.cacheTables = true
26+
}
27+
28+
override def afterAll() {
29+
TestHive.cacheTables = false
30+
}
31+
}
2132

2233
/**
2334
* Runs the test cases that are included in the hive distribution.

0 commit comments

Comments
 (0)