Github user nsyca commented on a diff in the pull request:
https://github.com/apache/spark/pull/17186#discussion_r106169573
--- 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 --
I am aware of it. My point is when users turn on this setting in hope of
alleviating a lengthy compilation time, they will get this "unintentional" side
effect that could lengthen the execution time of evaluating the same predicate
twice.
Overall, I agree with your approach but the point I raised could be a
followup work.
---
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]