GitHub user liancheng opened a pull request:
https://github.com/apache/spark/pull/3784
[SPARK-4937] Normalizes conjunctions and disjunctions to eliminate common
predicates
This PR is a simplified version of several filter optimization rules
introduced in #3778. Newly introduced optimizations include:
1. `a && a` => `a`
2. `a || a` => `a`
3. `(a || b || c || ...) && (a || b || d || ...)` => `a && b && (c || d ||
...)`
The 3rd rule is particularly useful to optimize the following query, which
is planned into a cartesian product
```sql
SELECT *
FROM t1, t2
WHERE (t1.key = t2.key AND t1.value > 10)
OR (t1.key = t2.key AND t2.value < 20)
```
to the following one, which is planned into an equi-join:
```sql
SELECT *
FROM t1, t2
WHERE t1.key = t2.key
AND (t1.value > 10 OR t2.value < 20)
```
The example above is quite artificial, but common predicates are likely to
appear in real life complex queries (like the one mentioned in #3778.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/liancheng/spark normalize-filters
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/3784.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3784
----
commit cf95639d6ea9f5027a4a4612088e5cc67c6d3470
Author: Cheng Lian <[email protected]>
Date: 2014-12-24T05:42:39Z
Adds an optimization rule for filter normalization
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]