-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(optimizer): convert filter predicate to CNF to push through join (…
…#3623) By converting the predicate to Conjunctive Normal Form, we are able to split the predicate into expressions that are isolated to the schemas of an individual side of a join. Then, we can split by conjunctions and push those new expressions through the joins. For example, consider the schemas: ``` left = [a: Utf8] right = [b: Utf8] ``` If our plan was ``` Filter | by: (col(a) = "FRANCE" & col("b") = "GERMANY") | (col(a) = "GERMANY" & col("b") = "FRANCE") | Join | \ | Scan(right) Scan(left) ``` That filter predicate in CNF is ``` (col(a) = "FRANCE" | col(a) = "GERMANY") & (col(a) = "FRANCE" | col(b) = "FRANCE") & (col(b) = "GERMANY" | col(a) = "GERMANY") & (col(b) = "GERMANY" | col(b) = "FRANCE") ``` The first and last expressions in this conjunction only have columns from a single side of the join, so can be pushed down, resulting in this optimized plan: ``` Filter | by: (col(a) = "FRANCE" | col(b) = "FRANCE") & (col(b) = "GERMANY" | col(a) = "GERMANY") | Join | \ | Scan(right) | pushdowns: Filter { (col(b) = "GERMANY" | col(b) = "FRANCE") } Scan(left) |. pushdowns: Filter { (col(a) = "FRANCE" | col(a) = "GERMANY") } ```
- Loading branch information
1 parent
07f6b2c
commit 28d3fa7
Showing
2 changed files
with
238 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters