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 cfca93bbf0659ef07ae572f1a8d735a0d4834c7e..4c1b425b163c0c7e6a5ab1bca6af76c9b1ecfc38 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 @@ -480,7 +480,11 @@ abstract class HiveComparisonTest val executions = queryList.map(new TestHive.QueryExecution(_)) executions.foreach(_.toRdd) val tablesGenerated = queryList.zip(executions).flatMap { - case (q, e) => e.sparkPlan.collect { + // We should take executedPlan instead of sparkPlan, because in following codes we + // will run the collected plans. As we will do extra processing for sparkPlan such + // as adding exchage, collapsing codegen stages, etc., collecing sparkPlan here + // will cause some errors when running these plans later. + case (q, e) => e.executedPlan.collect { case i: InsertIntoHiveTable if tablesRead contains i.table.tableName => (q, e, i) }