Skip to content

Commit 527e6ce

Browse files
committed
minor comment improvements
1 parent 5c6f134 commit 527e6ce

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

sql/catalyst/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<groupId>org.scala-lang</groupId>
4545
<artifactId>scala-reflect</artifactId>
4646
</dependency>
47-
47+
4848
<dependency>
4949
<groupId>org.apache.spark</groupId>
5050
<artifactId>spark-core_${scala.binary.version}</artifactId>

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.spark.sql.catalyst.optimizer
1919

2020
import scala.collection.immutable.HashSet
21-
2221
import org.apache.spark.sql.catalyst.expressions._
2322
import org.apache.spark.sql.catalyst.plans.Inner
2423
import org.apache.spark.sql.catalyst.plans.FullOuter
@@ -313,19 +312,20 @@ object BooleanSimplification extends Rule[LogicalPlan] with PredicateHelper {
313312
// a && a => a
314313
case (l, r) if l fastEquals r => l
315314
case (_, _) =>
316-
// (a && b && c && ...) || (a && b && d && ...) || (a && b && e && ...) ... =>
317-
// a && b && ((c && ...) || (d && ...) || (e && ...) || ...)
318315
val lhsSet = splitDisjunctivePredicates(left).toSet
319316
val rhsSet = splitDisjunctivePredicates(right).toSet
320317
val common = lhsSet.intersect(rhsSet)
321318
val ldiff = lhsSet.diff(common)
322319
val rdiff = rhsSet.diff(common)
323-
324320
if (common.size == 0) {
321+
// a && b
325322
and
326323
}else if (ldiff.size == 0 || rdiff.size == 0) {
324+
// a && (a || b)
327325
common.reduce(Or)
328326
} else {
327+
// (a || b || c || ...) && (a || b || d || ...) && (a || b || e || ...) ... =>
328+
// (a || b) || ((c || ...) && (f || ...) && (e || ...) && ...)
329329
(ldiff.reduceOption(Or) ++ rdiff.reduceOption(Or))
330330
.reduceOption(And)
331331
.map(_ :: common.toList)
@@ -343,18 +343,20 @@ object BooleanSimplification extends Rule[LogicalPlan] with PredicateHelper {
343343
// a || a => a
344344
case (l, r) if l fastEquals r => l
345345
case (_, _) =>
346-
// (a || b || c || ...) && (a || b || d || ...) && (a || b || e || ...) ... =>
347-
// (a || b) || ((c || ...) && (f || ...) && (e || ...) && ...)
348346
val lhsSet = splitConjunctivePredicates(left).toSet
349347
val rhsSet = splitConjunctivePredicates(right).toSet
350348
val common = lhsSet.intersect(rhsSet)
351349
val ldiff = lhsSet.diff(common)
352350
val rdiff = rhsSet.diff(common)
353351
if (common.size == 0) {
352+
// a || b
354353
or
355354
}else if ( ldiff.size == 0 || rdiff.size == 0) {
355+
// a || (b && a)
356356
common.reduce(And)
357357
} else {
358+
// (a && b && c && ...) || (a && b && d && ...) || (a && b && e && ...) ... =>
359+
// a && b && ((c && ...) || (d && ...) || (e && ...) || ...)
358360
(ldiff.reduceOption(And) ++ rdiff.reduceOption(And))
359361
.reduceOption(Or)
360362
.map(_ :: common.toList)

0 commit comments

Comments
 (0)