Skip to content

Commit

Permalink
Fix createFilter for NOT queries (apache#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwoody authored Nov 23, 2016
1 parent 813a33f commit 9c256a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private[parquet] object ParquetFilters {
} yield FilterApi.or(lhsFilter, rhsFilter)

case sources.Not(pred) =>
createFilter(schema, pred).map(FilterApi.not)
createFilter(schema, pred).map(FilterApi.not).map(LogicalInverseRewriter.rewrite)

case sources.In(name, values) if dataTypeOf.contains(name) =>
val eq = makeEq.lift(dataTypeOf(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,19 @@ class ParquetQuerySuite extends QueryTest with ParquetTest with SharedSQLContext
}
}
}

test("Ensure proper rewriting of predicates") {
withSQLConf(ParquetOutputFormat.JOB_SUMMARY_LEVEL -> "ALL",
SQLConf.FILES_OPEN_COST_IN_BYTES.key -> (128 * 1024 * 1024).toString) {
withTempPath { path =>
spark.sparkContext.parallelize(Seq(1, 2, 3), 3)
.toDF("x").write.parquet(path.getCanonicalPath)
val df = spark.read.parquet(path.getCanonicalPath)
val column: Column = !df.col("x").isNull
assert(df.filter(column).collect().length == 3)
}
}
}
}

class CountingFileSystem extends RawLocalFileSystem {
Expand Down

0 comments on commit 9c256a4

Please sign in to comment.