Skip to content
Snippets Groups Projects
Commit db11ee5e authored by tedyu's avatar tedyu Committed by Yin Huai
Browse files

[SPARK-11371] Make "mean" an alias for "avg" operator

From Reynold in the thread 'Exception when using some aggregate operators' (http://search-hadoop.com/m/q3RTt0xFr22nXB4/):

I don't think these are bugs. The SQL standard for average is "avg", not "mean". Similarly, a distinct count is supposed to be written as "count(distinct col)", not "countDistinct(col)".
We can, however, make "mean" an alias for "avg" to improve compatibility between DataFrame and SQL.

Author: tedyu <yuzhihong@gmail.com>

Closes #9332 from ted-yu/master.
parent 33ae7a35
No related branches found
No related tags found
No related merge requests found
......@@ -185,6 +185,7 @@ object FunctionRegistry {
expression[Last]("last"),
expression[Last]("last_value"),
expression[Max]("max"),
expression[Average]("mean"),
expression[Min]("min"),
expression[Stddev]("stddev"),
expression[StddevPop]("stddev_pop"),
......
......@@ -298,6 +298,15 @@ abstract class AggregationQuerySuite extends QueryTest with SQLTestUtils with Te
""".stripMargin),
Row(1, 20.0) :: Row(2, -0.5) :: Row(3, null) :: Row(null, 10.0) :: Nil)
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(
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment