Skip to content

Commit 171a9e6

Browse files
committed
update
1 parent c44a589 commit 171a9e6

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -762,35 +762,37 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto
762762

763763
test("auto converts to broadcast join by size estimate of scanned partitions " +
764764
"for partitioned table") {
765-
withTempView("tempTbl", "largeTbl", "partTbl") {
766-
spark.range(0, 1000, 1, 2).selectExpr("id as col1", "id as col2")
767-
.createOrReplaceTempView("tempTbl")
768-
spark.range(0, 100000, 1, 2).selectExpr("id as col1", "id as col2").
769-
createOrReplaceTempView("largeTbl")
770-
sql("CREATE TABLE partTbl (col1 INT, col2 STRING) " +
771-
"PARTITIONED BY (part1 STRING, part2 INT) STORED AS textfile")
772-
for (part1 <- Seq("a", "b", "c", "d"); part2 <- Seq(1, 2)) {
773-
sql(
774-
s"""
775-
|INSERT OVERWRITE TABLE partTbl PARTITION (part1='$part1',part2='$part2')
776-
|select col1, col2 from tempTbl
765+
withTempView("tempTbl", "largeTbl") {
766+
withTable("partTbl") {
767+
spark.range(0, 1000, 1, 2).selectExpr("id as col1", "id as col2")
768+
.createOrReplaceTempView("tempTbl")
769+
spark.range(0, 100000, 1, 2).selectExpr("id as col1", "id as col2")
770+
.createOrReplaceTempView("largeTbl")
771+
sql("CREATE TABLE partTbl (col1 INT, col2 STRING) " +
772+
"PARTITIONED BY (part1 STRING, part2 INT) STORED AS textfile")
773+
for (part1 <- Seq("a", "b", "c", "d"); part2 <- Seq(1, 2)) {
774+
sql(
775+
s"""
776+
|INSERT OVERWRITE TABLE partTbl PARTITION (part1='$part1',part2='$part2')
777+
|select col1, col2 from tempTbl
777778
""".stripMargin)
778-
}
779-
val query = "select * from largeTbl join partTbl on (largeTbl.col1 = partTbl.col1 " +
780-
"and partTbl.part1 = 'a' and partTbl.part2 = 1)"
781-
withSQLConf(SQLConf.ENABLE_FALL_BACK_TO_HDFS_FOR_STATS.key -> "true",
782-
SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "8001") {
783-
784-
withSQLConf(SQLConf.HIVE_METASTORE_PARTITION_PRUNING.key -> "true") {
785-
val broadcastJoins =
786-
sql(query).queryExecution.sparkPlan.collect { case j: BroadcastHashJoinExec => j }
787-
assert(broadcastJoins.nonEmpty)
788779
}
789-
790-
withSQLConf(SQLConf.HIVE_METASTORE_PARTITION_PRUNING.key -> "false") {
791-
val broadcastJoins =
792-
sql(query).queryExecution.sparkPlan.collect { case j: BroadcastHashJoinExec => j }
793-
assert(broadcastJoins.isEmpty)
780+
val query = "select * from largeTbl join partTbl on (largeTbl.col1 = partTbl.col1 " +
781+
"and partTbl.part1 = 'a' and partTbl.part2 = 1)"
782+
withSQLConf(SQLConf.ENABLE_FALL_BACK_TO_HDFS_FOR_STATS.key -> "true",
783+
SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "8001") {
784+
785+
withSQLConf(SQLConf.HIVE_METASTORE_PARTITION_PRUNING.key -> "true") {
786+
val broadcastJoins =
787+
sql(query).queryExecution.sparkPlan.collect { case j: BroadcastHashJoinExec => j }
788+
assert(broadcastJoins.nonEmpty)
789+
}
790+
791+
withSQLConf(SQLConf.HIVE_METASTORE_PARTITION_PRUNING.key -> "false") {
792+
val broadcastJoins =
793+
sql(query).queryExecution.sparkPlan.collect { case j: BroadcastHashJoinExec => j }
794+
assert(broadcastJoins.isEmpty)
795+
}
794796
}
795797
}
796798
}

0 commit comments

Comments
 (0)