|
17 | 17 |
|
18 | 18 | package org.apache.spark.sql.hive.execution |
19 | 19 |
|
| 20 | +import org.scalatest.Matchers._ |
| 21 | + |
20 | 22 | import org.apache.spark.sql.QueryTest |
21 | 23 | import org.apache.spark.sql.catalyst.TableIdentifier |
22 | 24 | import org.apache.spark.sql.catalyst.dsl.expressions._ |
23 | 25 | import org.apache.spark.sql.catalyst.dsl.plans._ |
24 | | -import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project} |
| 26 | +import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project, ResolvedHint} |
25 | 27 | import org.apache.spark.sql.catalyst.rules.RuleExecutor |
26 | 28 | import org.apache.spark.sql.execution.datasources.{CatalogFileIndex, HadoopFsRelation, LogicalRelation, PruneFileSourcePartitions} |
27 | 29 | import org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat |
| 30 | +import org.apache.spark.sql.execution.joins.BroadcastHashJoinExec |
| 31 | +import org.apache.spark.sql.functions.broadcast |
28 | 32 | import org.apache.spark.sql.hive.test.TestHiveSingleton |
| 33 | +import org.apache.spark.sql.internal.SQLConf |
29 | 34 | import org.apache.spark.sql.test.SQLTestUtils |
30 | 35 | import org.apache.spark.sql.types.StructType |
31 | 36 |
|
@@ -91,4 +96,16 @@ class PruneFileSourcePartitionsSuite extends QueryTest with SQLTestUtils with Te |
91 | 96 | assert(size2 < tableStats.get.sizeInBytes) |
92 | 97 | } |
93 | 98 | } |
| 99 | + |
| 100 | + test("SPARK-26576 Broadcast hint not applied to partitioned table") { |
| 101 | + withTable("tbl") { |
| 102 | + withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1") { |
| 103 | + spark.range(10).selectExpr("id", "id % 3 as p").write.partitionBy("p").saveAsTable("tbl") |
| 104 | + val df = spark.table("tbl") |
| 105 | + val qe = df.join(broadcast(df), "p").queryExecution |
| 106 | + qe.optimizedPlan.collect { case _: ResolvedHint => } should have size 1 |
| 107 | + qe.sparkPlan.collect { case j: BroadcastHashJoinExec => j } should have size 1 |
| 108 | + } |
| 109 | + } |
| 110 | + } |
94 | 111 | } |
0 commit comments