Skip to content

Commit df08390

Browse files
committed
address comments
1 parent ccba836 commit df08390

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PruneFileSourcePartitions.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ private[sql] object PruneFileSourcePartitions
6363
val extraPartitionFilters =
6464
remainingFilterInCnf.filter(f => f.references.subsetOf(partitionSet))
6565

66+
// For the filters that can't be used for partition pruning, we simply use `remainingFilters`
67+
// instead of using the non-convertible part from `remainingFilterInCnf`. Otherwise, the
68+
// result filters can be very long.
6669
(ExpressionSet(partitionFilters ++ extraPartitionFilters), remainingFilters)
6770
}
6871

sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/PruneHiveTablePartitions.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.apache.spark.sql.catalyst.planning.PhysicalOperation
2727
import org.apache.spark.sql.catalyst.plans.logical.{Filter, LogicalPlan, Project}
2828
import org.apache.spark.sql.catalyst.rules.Rule
2929
import org.apache.spark.sql.execution.datasources.DataSourceStrategy
30-
import org.apache.spark.sql.execution.datasources.PruneFileSourcePartitions.CNFConversion
3130
import org.apache.spark.sql.internal.SQLConf
3231

3332
/**
@@ -110,9 +109,7 @@ private[sql] class PruneHiveTablePartitions(session: SparkSession)
110109
override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
111110
case op @ PhysicalOperation(projections, filters, relation: HiveTableRelation)
112111
if filters.nonEmpty && relation.isPartitioned && relation.prunedPartitions.isEmpty =>
113-
val predicates = CNFConversion(filters.reduceLeft(And))
114-
val finalPredicates = if (predicates.nonEmpty) predicates else filters
115-
val partitionKeyFilters = getPartitionKeyFilters(finalPredicates, relation)
112+
val partitionKeyFilters = getPartitionKeyFilters(filters, relation)
116113
if (partitionKeyFilters.nonEmpty) {
117114
val newPartitions = prunePartitions(relation, partitionKeyFilters)
118115
val newTableMeta = updateTableMeta(relation.tableMeta, newPartitions)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class PrunePartitionSuiteBase extends QueryTest with SQLTestUtils with
6767
}
6868
}
6969

70-
test("SPARK-32284: Avoid pushing down too many predicates in partition pruning") {
70+
test("SPARK-32284: Avoid expanding too many CNF predicates in partition pruning") {
7171
withTempView("temp") {
7272
withTable("t") {
7373
sql(

0 commit comments

Comments
 (0)