Skip to content

Commit eead87e

Browse files
HyukjinKwonrxin
authored andcommitted
[SPARK-9814] [SQL] EqualNotNull not passing to data sources
Author: hyukjinkwon <gurwls223@gmail.com> Author: 권혁진 <gurwls223@gmail.com> Closes #8096 from HyukjinKwon/master. (cherry picked from commit 00c0272) Signed-off-by: Reynold Xin <rxin@databricks.com>
1 parent e9d1eab commit eead87e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ private[sql] object DataSourceStrategy extends Strategy with Logging {
349349
case expressions.EqualTo(Literal(v, _), a: Attribute) =>
350350
Some(sources.EqualTo(a.name, v))
351351

352+
case expressions.EqualNullSafe(a: Attribute, Literal(v, _)) =>
353+
Some(sources.EqualNullSafe(a.name, v))
354+
case expressions.EqualNullSafe(Literal(v, _), a: Attribute) =>
355+
Some(sources.EqualNullSafe(a.name, v))
356+
352357
case expressions.GreaterThan(a: Attribute, Literal(v, _)) =>
353358
Some(sources.GreaterThan(a.name, v))
354359
case expressions.GreaterThan(Literal(v, _), a: Attribute) =>

sql/core/src/main/scala/org/apache/spark/sql/sources/filters.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ abstract class Filter
3636
*/
3737
case class EqualTo(attribute: String, value: Any) extends Filter
3838

39+
/**
40+
* Performs equality comparison, similar to [[EqualTo]]. However, this differs from [[EqualTo]]
41+
* in that it returns `true` (rather than NULL) if both inputs are NULL, and `false`
42+
* (rather than NULL) if one of the input is NULL and the other is not NULL.
43+
*
44+
* @since 1.5.0
45+
*/
46+
case class EqualNullSafe(attribute: String, value: Any) extends Filter
47+
3948
/**
4049
* A filter that evaluates to `true` iff the attribute evaluates to a value
4150
* greater than `value`.

sql/core/src/test/scala/org/apache/spark/sql/sources/FilteredScanSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ case class SimpleFilteredScan(from: Int, to: Int)(@transient val sqlContext: SQL
5656
// Predicate test on integer column
5757
def translateFilterOnA(filter: Filter): Int => Boolean = filter match {
5858
case EqualTo("a", v) => (a: Int) => a == v
59+
case EqualNullSafe("a", v) => (a: Int) => a == v
5960
case LessThan("a", v: Int) => (a: Int) => a < v
6061
case LessThanOrEqual("a", v: Int) => (a: Int) => a <= v
6162
case GreaterThan("a", v: Int) => (a: Int) => a > v

0 commit comments

Comments
 (0)