File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
main/scala/org/apache/spark/sql/execution/datasources/jdbc
test/scala/org/apache/spark/sql/jdbc Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ private[sql] class JDBCRDD(
305305 * `filters`, but as a WHERE clause suitable for injection into a SQL query.
306306 */
307307 private val filterWhereClause : String =
308- filters.flatMap(JDBCRDD .compileFilter).mkString(" AND " )
308+ filters.flatMap(JDBCRDD .compileFilter).map(p => s " ( $p ) " ). mkString(" AND " )
309309
310310 /**
311311 * A WHERE clause representing both `filters`, if any, and the current partition.
Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ class JDBCSuite extends SparkFunSuite
233233 assert(checkPushdown(sql(" SELECT * FROM foobar WHERE NAME LIKE 'fr%'" )).collect().size == 1 )
234234 assert(checkPushdown(sql(" SELECT * FROM foobar WHERE NAME LIKE '%ed'" )).collect().size == 1 )
235235 assert(checkPushdown(sql(" SELECT * FROM foobar WHERE NAME LIKE '%re%'" )).collect().size == 1 )
236+ val orPrecedenceSql =
237+ " SELECT * FROM foobar WHERE (NAME = 'fred' OR THEID = 100) AND THEID < 1"
238+ assert(checkPushdown(sql(orPrecedenceSql)).collect().size == 0 )
239+
236240 assert(checkPushdown(sql(" SELECT * FROM nulltypes WHERE A IS NULL" )).collect().size == 1 )
237241 assert(checkPushdown(sql(" SELECT * FROM nulltypes WHERE A IS NOT NULL" )).collect().size == 0 )
238242
You can’t perform that action at this time.
0 commit comments