diff options
author | Davies Liu <davies.liu@gmail.com> | 2015-08-01 00:41:15 -0700 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2015-08-01 00:41:15 -0700 |
commit | 60ea7ab4bbfaea29a6cdf4e0e71ddc56afd04de6 (patch) | |
tree | c3a12b90f6c9730c05e4e3b41114277227a609e7 /sql/core | |
parent | 1d59a4162bf5142af270ed7f4b3eab42870c87b7 (diff) | |
download | spark-60ea7ab4bbfaea29a6cdf4e0e71ddc56afd04de6.tar.gz spark-60ea7ab4bbfaea29a6cdf4e0e71ddc56afd04de6.tar.bz2 spark-60ea7ab4bbfaea29a6cdf4e0e71ddc56afd04de6.zip |
Revert "[SPARK-8232] [SQL] Add sort_array support"
This reverts commit 67ad4e21fc68336b0ad6f9a363fb5ebb51f592bf.
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/functions.scala | 19 | ||||
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala | 51 |
2 files changed, 6 insertions, 64 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index 3c9421f5cd..57bb00a741 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -2223,30 +2223,19 @@ object functions { ////////////////////////////////////////////////////////////////////////////////////////////// /** - * Returns length of array or map. - * + * Returns length of array or map * @group collection_funcs * @since 1.5.0 */ - def size(e: Column): Column = Size(e.expr) + def size(columnName: String): Column = size(Column(columnName)) /** - * Sorts the input array for the given column in ascending order, - * according to the natural ordering of the array elements. - * + * Returns length of array or map * @group collection_funcs * @since 1.5.0 */ - def sort_array(e: Column): Column = sort_array(e, true) + def size(column: Column): Column = Size(column.expr) - /** - * Sorts the input array for the given column in ascending / descending order, - * according to the natural ordering of the array elements. - * - * @group collection_funcs - * @since 1.5.0 - */ - def sort_array(e: Column, asc: Boolean): Column = SortArray(e.expr, lit(asc).expr) ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala index 46921d1425..1baec5d376 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala @@ -267,53 +267,6 @@ class DataFrameFunctionsSuite extends QueryTest { ) } - test("sort_array function") { - val df = Seq( - (Array[Int](2, 1, 3), Array("b", "c", "a")), - (Array[Int](), Array[String]()), - (null, null) - ).toDF("a", "b") - checkAnswer( - df.select(sort_array($"a"), sort_array($"b")), - Seq( - Row(Seq(1, 2, 3), Seq("a", "b", "c")), - Row(Seq[Int](), Seq[String]()), - Row(null, null)) - ) - checkAnswer( - df.select(sort_array($"a", false), sort_array($"b", false)), - Seq( - Row(Seq(3, 2, 1), Seq("c", "b", "a")), - Row(Seq[Int](), Seq[String]()), - Row(null, null)) - ) - checkAnswer( - df.selectExpr("sort_array(a)", "sort_array(b)"), - Seq( - Row(Seq(1, 2, 3), Seq("a", "b", "c")), - Row(Seq[Int](), Seq[String]()), - Row(null, null)) - ) - checkAnswer( - df.selectExpr("sort_array(a, true)", "sort_array(b, false)"), - Seq( - Row(Seq(1, 2, 3), Seq("c", "b", "a")), - Row(Seq[Int](), Seq[String]()), - Row(null, null)) - ) - - val df2 = Seq((Array[Array[Int]](Array(2)), "x")).toDF("a", "b") - assert(intercept[AnalysisException] { - df2.selectExpr("sort_array(a)").collect() - }.getMessage().contains("Type ArrayType(IntegerType,false) is not the AtomicType, " + - "we can not perform the ordering operations")) - - val df3 = Seq(("xxx", "x")).toDF("a", "b") - assert(intercept[AnalysisException] { - df3.selectExpr("sort_array(a)").collect() - }.getMessage().contains("ArrayType(AtomicType) is expected, but we got StringType")) - } - test("array size function") { val df = Seq( (Array[Int](1, 2), "x"), @@ -321,7 +274,7 @@ class DataFrameFunctionsSuite extends QueryTest { (Array[Int](1, 2, 3), "z") ).toDF("a", "b") checkAnswer( - df.select(size($"a")), + df.select(size("a")), Seq(Row(2), Row(0), Row(3)) ) checkAnswer( @@ -337,7 +290,7 @@ class DataFrameFunctionsSuite extends QueryTest { (Map[Int, Int](1 -> 1, 2 -> 2, 3 -> 3), "z") ).toDF("a", "b") checkAnswer( - df.select(size($"a")), + df.select(size("a")), Seq(Row(2), Row(0), Row(3)) ) checkAnswer( |