Skip to content

Commit cd5693f

Browse files
committed
Update tests
1 parent 6b4d48e commit cd5693f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
7676
checkRewrite(RewriteDistinctAggregates(input))
7777
}
7878

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

94-
test("reduce multiple distinct groups due to superficial differences") {
94+
test("SPARK-40382: reduce multiple distinct groups due to superficial differences") {
9595
val input = testRelation
9696
.groupBy($"a")(
9797
countDistinct($"b" + $"c" + $"d").as("agg1"),

sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,22 @@ class DataFrameAggregateSuite extends QueryTest
14511451
val df = Seq(1).toDF("id").groupBy(Stream($"id" + 1, $"id" + 2): _*).sum("id")
14521452
checkAnswer(df, Row(2, 3, 1))
14531453
}
1454+
1455+
test("SPARK-40382: All distinct aggregation children are semantically equivalent") {
1456+
val df = Seq(
1457+
(1, 1, 1),
1458+
(1, 2, 3),
1459+
(1, 2, 3),
1460+
(2, 1, 1),
1461+
(2, 2, 5)
1462+
).toDF("k", "c1", "c2")
1463+
val res1 = df.groupBy("k")
1464+
.agg(sum("c1"), countDistinct($"c2" + 1), sum_distinct(lit(1) + $"c2"))
1465+
checkAnswer(res1, Row(1, 5, 2, 6) :: Row(2, 3, 2, 8) :: Nil)
1466+
1467+
val res2 = df.selectExpr("count(distinct C2)", "count(distinct c2)")
1468+
checkAnswer(res2, Row(3, 3) :: Nil)
1469+
}
14541470
}
14551471

14561472
case class B(c: Option[Double])

0 commit comments

Comments
 (0)