Skip to content

Commit 7f443a6

Browse files
HyukjinKwonrxin
authored andcommitted
[SPARK-12314][SQL] isnull operator not pushed down for JDBC datasource.
https://issues.apache.org/jira/browse/SPARK-12314 `IsNull` filter is not being pushed down for JDBC datasource. It looks it is SQL standard according to [SQL-92](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt), SQL:1999, [SQL:2003](http://www.wiscorp.com/sql_2003_standard.zip) and [SQL:201x](http://www.wiscorp.com/sql20nn.zip) and I believe most databases support this. In this PR, I simply added the case for `IsNull` filter to produce a proper filter string. Author: hyukjinkwon <[email protected]> This patch had conflicts when merged, resolved by Committer: Reynold Xin <[email protected]> Closes #10286 from HyukjinKwon/SPARK-12314.
1 parent 0f6936b commit 7f443a6

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ private[sql] class JDBCRDD(
286286
case GreaterThan(attr, value) => s"$attr > ${compileValue(value)}"
287287
case LessThanOrEqual(attr, value) => s"$attr <= ${compileValue(value)}"
288288
case GreaterThanOrEqual(attr, value) => s"$attr >= ${compileValue(value)}"
289+
case IsNull(attr) => s"$attr IS NULL"
289290
case _ => null
290291
}
291292

sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class JDBCSuite extends SparkFunSuite with BeforeAndAfter with SharedSQLContext
182182
assert(stripSparkFilter(sql("SELECT * FROM foobar WHERE NAME = 'fred'")).collect().size === 1)
183183
assert(stripSparkFilter(sql("SELECT * FROM foobar WHERE NAME > 'fred'")).collect().size === 2)
184184
assert(stripSparkFilter(sql("SELECT * FROM foobar WHERE NAME != 'fred'")).collect().size === 2)
185+
assert(stripSparkFilter(sql("SELECT * FROM nulltypes WHERE A IS NULL")).collect().size === 1)
185186
}
186187

187188
test("SELECT * WHERE (quoted strings)") {

0 commit comments

Comments
 (0)