Skip to content

Commit ac79906

Browse files
committed
Merge branch 'master' of git://git.apache.org/spark into add-triple-slash-testcase
2 parents 6d4f47e + 5ce7dae commit ac79906

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

sql/core/src/main/scala/org/apache/spark/sql/columnar/InMemoryColumnarTableScan.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ private[sql] case class InMemoryColumnarTableScan(
182182
// to evaluate to `true' based on statistics collected about this partition batch.
183183
val buildFilter: PartialFunction[Expression, Expression] = {
184184
case And(lhs: Expression, rhs: Expression)
185-
if buildFilter.isDefinedAt(lhs) && buildFilter.isDefinedAt(rhs) =>
186-
buildFilter(lhs) && buildFilter(rhs)
185+
if buildFilter.isDefinedAt(lhs) || buildFilter.isDefinedAt(rhs) =>
186+
(buildFilter.lift(lhs) ++ buildFilter.lift(rhs)).reduce(_ && _)
187187

188188
case Or(lhs: Expression, rhs: Expression)
189189
if buildFilter.isDefinedAt(lhs) && buildFilter.isDefinedAt(rhs) =>

sql/core/src/test/scala/org/apache/spark/sql/columnar/PartitionBatchPruningSuite.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,23 @@ class PartitionBatchPruningSuite extends FunSuite with BeforeAndAfterAll with Be
7878
// Conjunction and disjunction
7979
checkBatchPruning("SELECT key FROM pruningData WHERE key > 8 AND key <= 21", 2, 3)(9 to 21)
8080
checkBatchPruning("SELECT key FROM pruningData WHERE key < 2 OR key > 99", 2, 2)(Seq(1, 100))
81+
checkBatchPruning("SELECT key FROM pruningData WHERE key < 12 AND key IS NOT NULL", 1, 2)(1 to 11)
8182
checkBatchPruning("SELECT key FROM pruningData WHERE key < 2 OR (key > 78 AND key < 92)", 3, 4) {
8283
Seq(1) ++ (79 to 91)
8384
}
85+
checkBatchPruning("SELECT key FROM pruningData WHERE NOT (key < 88)", 1, 2) {
86+
// Although the `NOT` operator isn't supported directly, the optimizer can transform
87+
// `NOT (a < b)` to `b >= a`
88+
88 to 100
89+
}
8490

8591
// With unsupported predicate
86-
checkBatchPruning("SELECT key FROM pruningData WHERE NOT (key < 88)", 1, 2)(88 to 100)
87-
checkBatchPruning("SELECT key FROM pruningData WHERE key < 12 AND key IS NOT NULL", 1, 2)(1 to 11)
88-
8992
{
9093
val seq = (1 to 30).mkString(", ")
9194
checkBatchPruning(s"SELECT key FROM pruningData WHERE NOT (key IN ($seq))", 5, 10)(31 to 100)
95+
checkBatchPruning(s"SELECT key FROM pruningData WHERE NOT (key IN ($seq)) AND key > 88", 1, 2) {
96+
89 to 100
97+
}
9298
}
9399

94100
def checkBatchPruning(

0 commit comments

Comments
 (0)