Skip to content

Commit bda0ba0

Browse files
committed
Improve tests
1 parent 4a9ffaa commit bda0ba0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
4949
comparePlans(input, rewrite)
5050
}
5151

52+
test("single distinct group with partial aggregates") {
53+
val input = testRelation
54+
.groupBy('a, 'd)(
55+
countDistinct('e, 'c).as('agg1),
56+
max('b).as('agg2))
57+
.analyze
58+
val rewrite = RewriteDistinctAggregates(input)
59+
comparePlans(input, rewrite)
60+
}
61+
5262
test("single distinct group with non-partial aggregates") {
5363
val input = testRelation
5464
.groupBy('a, 'd)(
@@ -59,15 +69,25 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
5969
}
6070

6171
test("multiple distinct groups") {
72+
val input = testRelation
73+
.groupBy('a)(countDistinct('b, 'c), countDistinct('d))
74+
.analyze
75+
checkRewrite(RewriteDistinctAggregates(input))
76+
}
77+
78+
test("multiple distinct groups with partial aggregates") {
6279
val input = testRelation
6380
.groupBy('a)(countDistinct('b, 'c), countDistinct('d), sum('e))
6481
.analyze
6582
checkRewrite(RewriteDistinctAggregates(input))
6683
}
6784

68-
test("multiple distinct groups without non-distinct aggregates") {
85+
test("multiple distinct groups with non-partial aggregates") {
6986
val input = testRelation
70-
.groupBy('a)(countDistinct('b, 'c), countDistinct('d))
87+
.groupBy('a)(
88+
countDistinct('b, 'c),
89+
countDistinct('d),
90+
CollectSet('b).toAggregateExpression())
7191
.analyze
7292
checkRewrite(RewriteDistinctAggregates(input))
7393
}

0 commit comments

Comments
 (0)