-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-13527] [SQL] Prune Filters based on Constraints #11406
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
Conversation
|
Test build #52095 has finished for PR 11406 at commit
|
|
Test build #52096 has finished for PR 11406 at commit
|
| comparePlans(optimized, correctAnswer) | ||
| } | ||
|
|
||
| test("Filter removal #1 -- isNull + LeftOuter") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PruneFiltersSuite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. will do
|
Test build #52111 has finished for PR 11406 at commit
|
|
Test build #52112 has finished for PR 11406 at commit
|
|
@marmbrus @sameeragarwal Could you please take a look at this rule? Thanks! |
| } else if (remainingPredicates.isEmpty) { | ||
| p | ||
| } else { | ||
| val newCond = remainingPredicates.reduceOption(And).getOrElse(Literal(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that you need the type ascription (: LogicalPlan) here or above in the match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove it. Thanks!
|
Test build #52509 has finished for PR 11406 at commit
|
|
Test build #52583 has finished for PR 11406 at commit
|
| /** | ||
| * Remove all the deterministic conditions in a [[Filter]] that are guaranteed to be true | ||
| * given the constraints on the child's output. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like SimplifyFilters is similar in purpose with this rule. Can we merge them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do it. Thanks!
|
Test build #52632 has finished for PR 11406 at commit
|
|
Thanks, merging to master. |
#### What changes were proposed in this pull request?
Remove all the deterministic conditions in a [[Filter]] that are contained in the Child's Constraints.
For example, the first query can be simplified to the second one.
```scala
val queryWithUselessFilter = tr1
.where("tr1.a".attr > 10 || "tr1.c".attr < 10)
.join(tr2.where('d.attr < 100), Inner, Some("tr1.a".attr === "tr2.a".attr))
.where(
("tr1.a".attr > 10 || "tr1.c".attr < 10) &&
'd.attr < 100 &&
"tr2.a".attr === "tr1.a".attr)
```
```scala
val query = tr1
.where("tr1.a".attr > 10 || "tr1.c".attr < 10)
.join(tr2.where('d.attr < 100), Inner, Some("tr1.a".attr === "tr2.a".attr))
```
#### How was this patch tested?
Six test cases are added.
Author: gatorsmile <[email protected]>
Closes apache#11406 from gatorsmile/FilterRemoval.
What changes were proposed in this pull request?
Remove all the deterministic conditions in a [[Filter]] that are contained in the Child's Constraints.
For example, the first query can be simplified to the second one.
How was this patch tested?
Six test cases are added.