Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses-you committed Jul 20, 2020
1 parent bc454b6 commit 8aee8a5
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.dsl.plans._
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.{MaxBy, MinBy}
import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules._
Expand Down Expand Up @@ -319,4 +320,15 @@ class EliminateSortsSuite extends PlanTest {
val correctAnswer = PushDownOptimizer.execute(noOrderByPlan.analyze)
comparePlans(optimized, correctAnswer)
}

test("SPARK-32360: Add MaxMinBy to support eliminate sorts") {
Seq(MaxBy(Symbol("a"), Symbol("b")), MinBy(Symbol("a"), Symbol("b"))).foreach { agg =>
val projectPlan = testRelation.select(Symbol("a"), Symbol("b"))
val unnecessaryOrderByPlan = projectPlan.orderBy(Symbol("a").asc)
val groupByPlan = unnecessaryOrderByPlan.groupBy(Symbol("a"))(agg)
val optimized = Optimize.execute(groupByPlan.analyze)
val correctAnswer = projectPlan.groupBy(Symbol("a"))(agg).analyze
comparePlans(optimized, correctAnswer)
}
}
}

0 comments on commit 8aee8a5

Please sign in to comment.