Skip to content

Commit 2f8f139

Browse files
committed
fix
1 parent 4d45c0a commit 2f8f139

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper {
14581458
*/
14591459
object EliminateLimits extends Rule[LogicalPlan] {
14601460
private def canEliminate(limitExpr: Expression, child: LogicalPlan): Boolean = {
1461-
limitExpr.foldable && child.maxRows.exists { _ <= limitExpr.eval().toString.toLong }
1461+
limitExpr.foldable && child.maxRows.exists { _ <= limitExpr.eval().asInstanceOf[Int] }
14621462
}
14631463

14641464
def apply(plan: LogicalPlan): LogicalPlan = plan transformDown {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ class CombiningLimitsSuite extends PlanTest {
109109
comparePlans(optimized3, query3)
110110

111111
// test sort after limit
112-
val query4 = testRelation.select().groupBy()(count(1))
112+
val query4 = testRelation.select(Symbol("a")).groupBy()(count(1))
113113
.orderBy(Symbol("a").asc).limit(1).analyze
114114
val optimized4 = Optimize.execute(query4)
115-
val expected4 = testRelation.select().groupBy()(count(1))
115+
val expected4 = testRelation.select(Symbol("a")).groupBy()(count(1))
116116
.orderBy(Symbol("a").asc).analyze
117117
comparePlans(optimized4, expected4)
118118
}

0 commit comments

Comments
 (0)