Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/7452#discussion_r34939483
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -391,26 +391,26 @@ object BooleanSimplification extends
Rule[LogicalPlan] with PredicateHelper {
// (a || b) && (a || c) => a || (b && c)
case _ =>
// 1. Split left and right to get the disjunctive predicates,
- // i.e. lhsSet = (a, b), rhsSet = (a, c)
+ // i.e. lhs = (a, b), rhs = (a, c)
// 2. Find the common predict between lhsSet and rhsSet, i.e.
common = (a)
// 3. Remove common predict from lhsSet and rhsSet, i.e. ldiff =
(b), rdiff = (c)
// 4. Apply the formula, get the optimized predicate: common ||
(ldiff && rdiff)
- val lhsSet = splitDisjunctivePredicates(left).toSet
- val rhsSet = splitDisjunctivePredicates(right).toSet
- val common = lhsSet.intersect(rhsSet)
+ val lhs = splitDisjunctivePredicates(left)
+ val rhs = splitDisjunctivePredicates(right)
+ val common = lhs.filter(e => rhs.exists(e.semanticEquals(_)))
if (common.isEmpty) {
// No common factors, return the original predicate
and
} else {
- val ldiff = lhsSet.diff(common)
- val rdiff = rhsSet.diff(common)
+ val ldiff = lhs.filterNot(e =>
common.exists(e.semanticEquals(_)))
+ val rdiff = rhs.filterNot(e =>
common.exists(e.semanticEquals(_)))
--- End diff --
Either that or `ExpressionSet`? I think this is okay for now though.
---
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]