Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bersprockets committed Sep 17, 2022
1 parent 6b4d48e commit cd5693f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
checkRewrite(RewriteDistinctAggregates(input))
}

test("eliminate multiple distinct groups due to superficial differences") {
test("SPARK-40382: eliminate multiple distinct groups due to superficial differences") {
val input = testRelation
.groupBy($"a")(
countDistinct($"b" + $"c").as("agg1"),
Expand All @@ -91,7 +91,7 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
}
}

test("reduce multiple distinct groups due to superficial differences") {
test("SPARK-40382: reduce multiple distinct groups due to superficial differences") {
val input = testRelation
.groupBy($"a")(
countDistinct($"b" + $"c" + $"d").as("agg1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,22 @@ class DataFrameAggregateSuite extends QueryTest
val df = Seq(1).toDF("id").groupBy(Stream($"id" + 1, $"id" + 2): _*).sum("id")
checkAnswer(df, Row(2, 3, 1))
}

test("SPARK-40382: All distinct aggregation children are semantically equivalent") {
val df = Seq(
(1, 1, 1),
(1, 2, 3),
(1, 2, 3),
(2, 1, 1),
(2, 2, 5)
).toDF("k", "c1", "c2")
val res1 = df.groupBy("k")
.agg(sum("c1"), countDistinct($"c2" + 1), sum_distinct(lit(1) + $"c2"))
checkAnswer(res1, Row(1, 5, 2, 6) :: Row(2, 3, 2, 8) :: Nil)

val res2 = df.selectExpr("count(distinct C2)", "count(distinct c2)")
checkAnswer(res2, Row(3, 3) :: Nil)
}
}

case class B(c: Option[Double])
Expand Down

0 comments on commit cd5693f

Please sign in to comment.