Skip to content

Commit

Permalink
[SPARK-48790][TESTING] Use checkDatasetUnorderly in DeprecatedDataset…
Browse files Browse the repository at this point in the history
…AggregatorSuite

### What changes were proposed in this pull request?

Use `checkDatasetUnorderly` in DeprecatedDatasetAggregatorSuite. The tests do not need depending on the ordering of the result.

### Why are the changes needed?

Improve test cases.

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

N/A

### Was this patch authored or co-authored using generative AI tooling?

NO

Closes apache#47196 from amaliujia/fix_tests.

Authored-by: Rui Wang <rui.wang@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
  • Loading branch information
amaliujia authored and cloud-fan committed Jul 3, 2024
1 parent bb59267 commit 2e210d9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class DeprecatedDatasetAggregatorSuite extends QueryTest with SharedSparkSession
test("typed aggregation: TypedAggregator") {
val ds = Seq(("a", 10), ("a", 20), ("b", 1), ("b", 2), ("c", 1)).toDS()

checkDataset(
checkDatasetUnorderly(
ds.groupByKey(_._1).agg(typed.sum(_._2)),
("a", 30.0), ("b", 3.0), ("c", 1.0))
}

test("typed aggregation: TypedAggregator, expr, expr") {
val ds = Seq(("a", 10), ("a", 20), ("b", 1), ("b", 2), ("c", 1)).toDS()

checkDataset(
checkDatasetUnorderly(
ds.groupByKey(_._1).agg(
typed.sum(_._2),
expr("sum(_2)").as[Long],
Expand All @@ -57,7 +57,7 @@ class DeprecatedDatasetAggregatorSuite extends QueryTest with SharedSparkSession

test("typed aggregate: avg, count, sum") {
val ds = Seq("a" -> 1, "a" -> 3, "b" -> 3).toDS()
checkDataset(
checkDatasetUnorderly(
ds.groupByKey(_._1).agg(
typed.avg(_._2), typed.count(_._2), typed.sum(_._2), typed.sumLong(_._2)),
("a", 2.0, 2L, 4.0, 4L), ("b", 3.0, 1L, 3.0, 3L))
Expand Down

0 comments on commit 2e210d9

Please sign in to comment.