diff options
author | jiangxingbo <jiangxb1987@gmail.com> | 2016-11-28 11:05:58 -0800 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2016-11-28 11:05:58 -0800 |
commit | 0f5f52a3d1e5dcf5b970c49e324e322b9deb00f3 (patch) | |
tree | 3324b94c8e4275c2bd2ac0bab7804835c7ccab59 /sql/hive/src | |
parent | 185642846e25fa812f9c7f398ab20bffc1e25273 (diff) | |
download | spark-0f5f52a3d1e5dcf5b970c49e324e322b9deb00f3.tar.gz spark-0f5f52a3d1e5dcf5b970c49e324e322b9deb00f3.tar.bz2 spark-0f5f52a3d1e5dcf5b970c49e324e322b9deb00f3.zip |
[SPARK-16282][SQL] Implement percentile SQL function.
## What changes were proposed in this pull request?
Implement percentile SQL function. It computes the exact percentile(s) of expr at pc with range in [0, 1].
## How was this patch tested?
Add a new testsuite `PercentileSuite` to test percentile directly.
Updated related testcases in `ExpressionToSQLSuite`.
Author: jiangxingbo <jiangxb1987@gmail.com>
Author: 蒋星博 <jiangxingbo@meituan.com>
Author: jiangxingbo <jiangxingbo@meituan.com>
Closes #14136 from jiangxb1987/percentile.
Diffstat (limited to 'sql/hive/src')
-rw-r--r-- | sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala | 3 | ||||
-rw-r--r-- | sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionToSQLSuite.scala | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala index 4a9b28a455..08bf1cd0ef 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala @@ -234,7 +234,6 @@ private[sql] class HiveSessionCatalog( // noopwithmapstreaming, parse_url_tuple, reflect2, windowingtablefunction. // Note: don't forget to update SessionCatalog.isTemporaryFunction private val hiveFunctions = Seq( - "histogram_numeric", - "percentile" + "histogram_numeric" ) } diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionToSQLSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionToSQLSuite.scala index fdd02821df..27ea167b90 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionToSQLSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionToSQLSuite.scala @@ -173,6 +173,8 @@ class ExpressionToSQLSuite extends SQLBuilderTest with SQLTestUtils { checkSqlGeneration("SELECT max(value) FROM t1 GROUP BY key") checkSqlGeneration("SELECT mean(value) FROM t1 GROUP BY key") checkSqlGeneration("SELECT min(value) FROM t1 GROUP BY key") + checkSqlGeneration("SELECT percentile(value, 0.25) FROM t1 GROUP BY key") + checkSqlGeneration("SELECT percentile(value, array(0.25, 0.75)) FROM t1 GROUP BY key") checkSqlGeneration("SELECT skewness(value) FROM t1 GROUP BY key") checkSqlGeneration("SELECT stddev(value) FROM t1 GROUP BY key") checkSqlGeneration("SELECT stddev_pop(value) FROM t1 GROUP BY key") |