Skip to content

Commit 70a3544

Browse files
committed
[SPARK-4693] [SQL] PruningPredicates may be wrong if predicates contains an empty AttributeSet() references
1 parent efa9b03 commit 70a3544

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,6 @@ class AttributeSet private (val baseSet: Set[AttributeEquals])
112112
override def toSeq: Seq[Attribute] = baseSet.map(_.a).toArray.toSeq
113113

114114
override def toString = "{" + baseSet.map(_.a).mkString(", ") + "}"
115+
116+
def isEmpty: Boolean = baseSet.isEmpty
115117
}

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,9 @@ private[hive] trait HiveStrategies {
194194
// Filter out all predicates that only deal with partition keys, these are given to the
195195
// hive table scan operator to be used for partition pruning.
196196
val partitionKeyIds = AttributeSet(relation.partitionKeys)
197-
val (pruningPredicates, otherPredicates) = predicates.partition { x =>
198-
x.references.baseSet != null &&
199-
!x.references.baseSet.isEmpty &&
200-
x.references.subsetOf(partitionKeyIds)
197+
val (pruningPredicates, otherPredicates) = predicates.partition { predicate =>
198+
!predicate.references.isEmpty &&
199+
predicate.references.subsetOf(partitionKeyIds)
201200
}
202201

203202
pruneFilterProject(

0 commit comments

Comments
 (0)