Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9332#discussion_r43670785
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala
---
@@ -323,6 +323,53 @@ abstract class AggregationQuerySuite extends QueryTest
with SQLTestUtils with Te
Row(11.125) :: Nil)
}
+ test("test mean no key in output") {
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT mean(value)
+ |FROM agg1
+ |GROUP BY key
+ """.stripMargin),
+ Row(-0.5) :: Row(20.0) :: Row(null) :: Row(10.0) :: Nil)
+ }
+
+ test("test mean") {
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT key, mean(value)
+ |FROM agg1
+ |GROUP BY key
+ """.stripMargin),
+ Row(1, 20.0) :: Row(2, -0.5) :: Row(3, null) :: Row(null, 10.0) ::
Nil)
+
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT mean(value), key
+ |FROM agg1
+ |GROUP BY key
+ """.stripMargin),
+ Row(20.0, 1) :: Row(-0.5, 2) :: Row(null, 3) :: Row(10.0, null) ::
Nil)
+
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT mean(value) + 1.5, key + 10
+ |FROM agg1
+ |GROUP BY key + 10
+ """.stripMargin),
+ Row(21.5, 11) :: Row(1.0, 12) :: Row(null, 13) :: Row(11.5, null) ::
Nil)
+
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT mean(value) FROM agg1
+ """.stripMargin),
+ Row(11.125) :: Nil)
+ }
+
--- End diff --
Thanks! Since this is a really small change, how about we just add a single
test to `test("test average")` instead of duplicating that test at here?
---
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]