Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/17186#discussion_r106167725
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/PruneFiltersSuite.scala
---
@@ -133,4 +146,28 @@ class PruneFiltersSuite extends PlanTest {
val correctAnswer = testRelation.where(Rand(10) > 5).where(Rand(10) >
5).select('a).analyze
comparePlans(optimized, correctAnswer)
}
+
+ test("No pruning when constraint propagation is disabled") {
+ val tr1 = LocalRelation('a.int, 'b.int, 'c.int).subquery('tr1)
+ val tr2 = LocalRelation('a.int, 'd.int, 'e.int).subquery('tr2)
+
+ 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))
+
+ val queryWithUselessFilter =
+ query.where(
+ ("tr1.a".attr > 10 || "tr1.c".attr < 10) &&
+ 'd.attr < 100)
+
+ val optimized =
OptimizeDisableConstraintPropagation.execute(queryWithUselessFilter.analyze)
+ // When constraint propagation is disabled, the useless filter won't
be pruned.
+ // It gets pushed down. Because the rule `CombineFilters` runs only
once, there are redundant
+ // and duplicate filters.
--- End diff --
What needs to clarify is, this behaviour is just limited to this test case.
That is why I added the comment. In normal optimization, `CombineFilters` will
run multiple times and the predicates will be combined.
---
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]