Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/13483#discussion_r65647111
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala ---
@@ -224,6 +224,21 @@ class DatasetAggregatorSuite extends QueryTest with
SharedSQLContext {
checkAnswer(df.groupBy($"j").agg(RowAgg.toColumn), Row("a", 1) ::
Row("b", 5) :: Nil)
}
+ test("SPARK-15688: Remove redundant expressions from aggregate") {
+ val df = Seq(1 -> "a", 2 -> "b", 3 -> "b").toDF("col1", "col2")
+ val df1 = df.groupBy("col1").agg($"col1", count("*"))
+ assert(df1.schema.map(_.name) === Seq("col1", "count(1)"))
+ val df2 = df.groupBy("col1", "col2").agg($"col1", count("*"))
+ assert(df2.schema.map(_.name) === Seq("col2", "col1", "count(1)"))
+ val df3 = df.groupBy(expr("col1 + 2")).agg(expr("col1 + 2"),
count("*"))
+ assert(df3.schema.map(_.name) === Seq("(col1 + 2)", "count(1)"))
+ val df4 = df.groupBy("col1").agg(min("col1"), max("col1"))
--- End diff --
Could you put some comments to show the goal of each test cases? The
comments can help reviewers understand the coverage of test cases. Thanks!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]