Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-15916][SQL] JDBC filter push down should respect operator precedence #13743

Closed
wants to merge 2 commits into from

Conversation

clockfly
Copy link
Contributor

@clockfly clockfly commented Jun 17, 2016

What changes were proposed in this pull request?

This PR fixes the problem that the precedence order is messed when pushing where-clause expression to JDBC layer.

Case 1:

For sql select * from table where (a or b) and c, the where-clause is wrongly converted to JDBC where-clause a or (b and c) after filter push down. The consequence is that JDBC may returns less or more rows than expected.

Case 2:

For sql select * from table where always_false_condition, the result table may not be empty if the JDBC RDD is partitioned using where-clause:

spark.read.jdbc(url, table, predicates = Array("partition 1 where clause", "partition 2 where clause"...)

How was this patch tested?

Unit test.

This PR also close #13640

@SparkQA
Copy link

SparkQA commented Jun 17, 2016

Test build #60729 has finished for PR 13743 at commit 2f1ada3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@liancheng
Copy link
Contributor

LGTM

@liancheng
Copy link
Contributor

Merging to master and branch-2.0.

@asfgit asfgit closed this in ebb9a3b Jun 18, 2016
asfgit pushed a commit that referenced this pull request Jun 18, 2016
…edence

## What changes were proposed in this pull request?

This PR fixes the problem that the precedence order is messed when pushing where-clause expression to JDBC layer.

**Case 1:**

For sql `select * from table where (a or b) and c`, the where-clause is wrongly converted to JDBC where-clause `a or (b and c)` after filter push down. The consequence is that JDBC may returns less or more rows than expected.

**Case 2:**

For sql `select * from table where always_false_condition`, the result table may not be empty if the JDBC RDD is partitioned using where-clause:
```
spark.read.jdbc(url, table, predicates = Array("partition 1 where clause", "partition 2 where clause"...)
```

## How was this patch tested?

Unit test.

This PR also close #13640

Author: hyukjinkwon <gurwls223@gmail.com>
Author: Sean Zhong <seanzhong@databricks.com>

Closes #13743 from clockfly/SPARK-15916.

(cherry picked from commit ebb9a3b)
Signed-off-by: Cheng Lian <lian@databricks.com>
zzcclp added a commit to zzcclp/spark that referenced this pull request Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants