Skip to content

Commit 78e19b5

Browse files
committed
Add test case
1 parent f7bca2f commit 78e19b5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/PruneFileSourcePartitionsSuite.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import org.apache.spark.sql.QueryTest
2121
import org.apache.spark.sql.catalyst.TableIdentifier
2222
import org.apache.spark.sql.catalyst.dsl.expressions._
2323
import org.apache.spark.sql.catalyst.dsl.plans._
24-
import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project}
24+
import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project, ResolvedHint}
2525
import org.apache.spark.sql.catalyst.rules.RuleExecutor
2626
import org.apache.spark.sql.execution.datasources.{CatalogFileIndex, HadoopFsRelation, LogicalRelation, PruneFileSourcePartitions}
2727
import org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat
@@ -91,4 +91,16 @@ class PruneFileSourcePartitionsSuite extends QueryTest with SQLTestUtils with Te
9191
assert(size2 < tableStats.get.sizeInBytes)
9292
}
9393
}
94+
95+
test("PruneFileSourcePartitions should not remove the hint") {
96+
withTable("t") {
97+
spark.range(2).selectExpr("id", "id as p").write.partitionBy("p").saveAsTable("t")
98+
val query = sql("select /*+ broadcastjoin(a) */ * from " +
99+
"(select id from t where p=1) a " )
100+
val hints = query.queryExecution.optimizedPlan.collect{
101+
case h: ResolvedHint => h
102+
}
103+
assert(hints.size === 1)
104+
}
105+
}
94106
}

0 commit comments

Comments
 (0)