Skip to content

Commit 1936ec6

Browse files
PR fixes
1 parent ce3e936 commit 1936ec6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ object RemoveRepetitionFromGroupExpressions extends Rule[LogicalPlan] {
17161716

17171717
/**
17181718
* Replaces GlobalLimit 0 and LocalLimit 0 nodes (subtree) with empty Local Relation, as they don't
1719-
* return any rows.
1719+
* return any rows.
17201720
*/
17211721
object OptimizeLimitZero extends Rule[LogicalPlan] {
17221722
// returns empty Local Relation corresponding to given plan
@@ -1734,7 +1734,7 @@ object OptimizeLimitZero extends Rule[LogicalPlan] {
17341734
// changes up the Logical Plan.
17351735
//
17361736
// Replace Global Limit 0 nodes with empty Local Relation
1737-
case gl @ GlobalLimit(IntegerLiteral(limit), _) if limit == 0 =>
1737+
case gl @ GlobalLimit(IntegerLiteral(0), _) =>
17381738
empty(gl)
17391739

17401740
// Note: For all SQL queries, if a LocalLimit 0 node exists in the Logical Plan, then a
@@ -1743,7 +1743,7 @@ object OptimizeLimitZero extends Rule[LogicalPlan] {
17431743
// then the following rule will handle that case as well.
17441744
//
17451745
// Replace Local Limit 0 nodes with empty Local Relation
1746-
case ll @ LocalLimit(IntegerLiteral(limit), _) if limit == 0 =>
1746+
case ll @ LocalLimit(IntegerLiteral(0), _) =>
17471747
empty(ll)
17481748
}
17491749
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/OptimizeLimitZeroSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ class OptimizeLimitZeroSuite extends PlanTest {
7171
(LeftOuter, Project(Seq('a, Literal(null).cast(IntegerType).as('b)), testRelation1).analyze),
7272
(RightOuter, LocalRelation('a.int, 'b.int)),
7373
(FullOuter, Project(Seq('a, Literal(null).cast(IntegerType).as('b)), testRelation1).analyze)
74-
).foreach { case (jt, answer) =>
74+
).foreach { case (jt, correctAnswer) =>
7575
test(s"Limit 0: for join type $jt") {
7676
val query = testRelation1
7777
.join(testRelation2.limit(0), joinType = jt, condition = Some('a.attr == 'b.attr))
7878

7979
val optimized = Optimize.execute(query.analyze)
80-
val correctAnswer = answer
8180

8281
comparePlans(optimized, correctAnswer)
8382
}

0 commit comments

Comments
 (0)