Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/2501#discussion_r18378504
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/CachedTableSuite.scala ---
@@ -17,22 +17,61 @@
package org.apache.spark.sql.hive
-import org.apache.spark.sql.execution.SparkLogicalPlan
+import org.apache.spark.sql.{QueryTest, SchemaRDD}
import org.apache.spark.sql.columnar.{InMemoryRelation,
InMemoryColumnarTableScan}
-import org.apache.spark.sql.hive.execution.HiveComparisonTest
import org.apache.spark.sql.hive.test.TestHive
-class CachedTableSuite extends HiveComparisonTest {
+class CachedTableSuite extends QueryTest {
import TestHive._
- TestHive.loadTestTable("src")
+ /**
+ * Throws a test failed exception when the number of cached tables
differs from the expected
+ * number.
+ */
+ def assertCached(query: SchemaRDD, numCachedTables: Int = 1): Unit = {
+ val planWithCaching = query.queryExecution.withCachedData
+ val cachedData = planWithCaching collect {
+ case cached: InMemoryRelation => cached
+ }
+
+ if (cachedData.size != numCachedTables) {
+ fail(
+ s"Expected query to contain $numCachedTables, but it actually had
${cachedData.size}\n" +
+ planWithCaching)
+ }
+ }
test("cache table") {
- TestHive.cacheTable("src")
+ val preCacheResults = sql("SELECT * FROM src").collect().toSeq
+
+ cacheTable("src")
+ assertCached(sql("SELECT * FROM src"))
+
+ checkAnswer(
+ sql("SELECT * FROM src"),
+ preCacheResults)
+
+
--- End diff --
Remove extra newline
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]