Github user huaxingao commented on a diff in the pull request: https://github.com/apache/spark/pull/10347#discussion_r47948040 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala --- @@ -288,6 +288,8 @@ private[sql] class JDBCRDD( case GreaterThanOrEqual(attr, value) => s"$attr >= ${compileValue(value)}" case IsNull(attr) => s"$attr IS NULL" case IsNotNull(attr) => s"$attr IS NOT NULL" + case Or(filter1, filter2) => + compileFilter (filter1) + " OR " + compileFilter (filter2) --- End diff -- @rxin Thank you very much for your comments. I will change the code to case Or(filter1, filter2) => "(" + compileFilter (filter1) + ") OR (" + compileFilter (filter2) + ")" The reason that I didn't add the AND filter along with OR is because I thought AND filter is not necessary. When I tried the simple test such as "select * from test where THEID = 1 and NAME = 'fred'", the filter passed to JDBC layer is an Array of filters with elements EqualTo(THEID,1), EqualTo(Name,fred). This can be handled by the current filter EqualTo and no need to add AND filter. But today, after more thinking, I found I still need to add AND. For query such as "SELECT * FROM foobar WHERE THEID = 1 OR NAME = 'mary' and THEID = 2" , the filter is Or(EqualTo(THEID,1),And(EqualTo(NAME,mary),EqualTo(THEID,2))) I will open another jira to add AND I also looked other filters: 1. LIKE For string column, SPARK used EqualTo. "Where columnName LIKE xxx" is changed to "Where columnName = xxx". I am not sure if SPARK intentionally changes LIKE to '='. In SQL, LIKE is not exactly the same as '=' 2. BETWEEN is changed to two filters GreatThanOrEqual, LessThanOrEqual. So current code works OK. No need to add anything 3. NOT BETWEEN is changed to Or(LessThanOrEqual, GreatThanOrEqual). No need to add anything. I will look more to see if I need to change other filters.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org