aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
index 2bdb0e1187..4d45249d9c 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
@@ -19,6 +19,8 @@ package org.apache.spark.sql.hive.execution
import java.io._
+import scala.util.control.NonFatal
+
import org.scalatest.{BeforeAndAfterAll, GivenWhenThen}
import org.apache.spark.{Logging, SparkFunSuite}
@@ -386,11 +388,45 @@ abstract class HiveComparisonTest
hiveCacheFiles.foreach(_.delete())
}
+ // If this query is reading other tables that were created during this test run
+ // also print out the query plans and results for those.
+ val computedTablesMessages: String = try {
+ val tablesRead = new TestHive.QueryExecution(query).executedPlan.collect {
+ case ts: HiveTableScan => ts.relation.tableName
+ }.toSet
+
+ TestHive.reset()
+ val executions = queryList.map(new TestHive.QueryExecution(_))
+ executions.foreach(_.toRdd)
+ val tablesGenerated = queryList.zip(executions).flatMap {
+ case (q, e) => e.executedPlan.collect {
+ case i: InsertIntoHiveTable if tablesRead contains i.table.tableName =>
+ (q, e, i)
+ }
+ }
+
+ tablesGenerated.map { case (hiveql, execution, insert) =>
+ s"""
+ |=== Generated Table ===
+ |$hiveql
+ |$execution
+ |== Results ==
+ |${insert.child.execute().collect().mkString("\n")}
+ """.stripMargin
+ }.mkString("\n")
+
+ } catch {
+ case NonFatal(e) =>
+ logError("Failed to compute generated tables", e)
+ s"Couldn't compute dependent tables: $e"
+ }
+
val errorMessage =
s"""
|Results do not match for $testCaseName:
|$hiveQuery\n${hiveQuery.analyzed.output.map(_.name).mkString("\t")}
|$resultComparison
+ |$computedTablesMessages
""".stripMargin
stringToFile(new File(wrongDirectory, testCaseName), errorMessage + consoleTestCase)