Repository: spark Updated Branches: refs/heads/branch-2.4 d3f5475a1 -> ae2ca0e5d refs/heads/master 9bb798f2e -> be454a7ce
Revert "[SPARK-25431][SQL][EXAMPLES] Fix function examples and unify the format of the example results." This reverts commit 9c25d7f735ed8c49c795babea3fda3cab226e7cb. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/be454a7c Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/be454a7c Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/be454a7c Branch: refs/heads/master Commit: be454a7cef1cb5c76fb22589fc3a55c1bf519cf4 Parents: 9bb798f Author: Takuya UESHIN <ues...@databricks.com> Authored: Sat Sep 15 12:50:46 2018 +0900 Committer: Takuya UESHIN <ues...@databricks.com> Committed: Sat Sep 15 12:50:46 2018 +0900 ---------------------------------------------------------------------- .../expressions/collectionOperations.scala | 49 ++++++++++---------- .../expressions/complexTypeCreator.scala | 4 +- .../expressions/higherOrderFunctions.scala | 32 ++++++------- 3 files changed, 42 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/be454a7c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala ---------------------------------------------------------------------- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala index 3ad21ec..ea6fccc 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala @@ -131,7 +131,7 @@ case class Size(child: Expression) extends UnaryExpression with ExpectsInputType examples = """ Examples: > SELECT _FUNC_(map(1, 'a', 2, 'b')); - [1, 2] + [1,2] """) case class MapKeys(child: Expression) extends UnaryExpression with ExpectsInputTypes { @@ -320,7 +320,7 @@ case class ArraysZip(children: Seq[Expression]) extends Expression with ExpectsI examples = """ Examples: > SELECT _FUNC_(map(1, 'a', 2, 'b')); - ["a", "b"] + ["a","b"] """) case class MapValues(child: Expression) extends UnaryExpression with ExpectsInputTypes { @@ -348,7 +348,7 @@ case class MapValues(child: Expression) examples = """ Examples: > SELECT _FUNC_(map(1, 'a', 2, 'b')); - [[1, "a"], [2, "b"]] + [(1,"a"),(2,"b")] """, since = "2.4.0") case class MapEntries(child: Expression) extends UnaryExpression with ExpectsInputTypes { @@ -516,7 +516,7 @@ case class MapEntries(child: Expression) extends UnaryExpression with ExpectsInp examples = """ Examples: > SELECT _FUNC_(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd')); - [1 -> "a", 2 -> "b", 2 -> "c", 3 -> "d"] + [[1 -> "a"], [2 -> "b"], [2 -> "c"], [3 -> "d"]] """, since = "2.4.0") case class MapConcat(children: Seq[Expression]) extends ComplexTypeMergingExpression { @@ -718,7 +718,7 @@ case class MapConcat(children: Seq[Expression]) extends ComplexTypeMergingExpres examples = """ Examples: > SELECT _FUNC_(array(struct(1, 'a'), struct(2, 'b'))); - [1 -> "a", 2 -> "b"] + {1:"a",2:"b"} """, since = "2.4.0") case class MapFromEntries(child: Expression) extends UnaryExpression { @@ -1071,7 +1071,7 @@ object ArraySortLike { examples = """ Examples: > SELECT _FUNC_(array('b', 'd', null, 'c', 'a'), true); - [null, "a", "b", "c", "d"] + [null,"a","b","c","d"] """) // scalastyle:on line.size.limit case class SortArray(base: Expression, ascendingOrder: Expression) @@ -1129,7 +1129,7 @@ case class SortArray(base: Expression, ascendingOrder: Expression) examples = """ Examples: > SELECT _FUNC_(array('b', 'd', null, 'c', 'a')); - ["a", "b", "c", "d", null] + ["a","b","c","d",null] """, since = "2.4.0") // scalastyle:on line.size.limit @@ -1254,7 +1254,7 @@ case class Shuffle(child: Expression, randomSeed: Option[Long] = None) examples = """ Examples: > SELECT _FUNC_('Spark SQL'); - "LQS krapS" + LQS krapS > SELECT _FUNC_(array(2, 1, 4, 3)); [3, 4, 1, 2] """, @@ -1634,9 +1634,9 @@ case class ArraysOverlap(left: Expression, right: Expression) examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3, 4), 2, 2); - [2, 3] + [2,3] > SELECT _FUNC_(array(1, 2, 3, 4), -2, 2); - [3, 4] + [3,4] """, since = "2.4.0") // scalastyle:on line.size.limit case class Slice(x: Expression, start: Expression, length: Expression) @@ -1745,11 +1745,11 @@ case class Slice(x: Expression, start: Expression, length: Expression) examples = """ Examples: > SELECT _FUNC_(array('hello', 'world'), ' '); - "hello world" + hello world > SELECT _FUNC_(array('hello', null ,'world'), ' '); - "hello world" + hello world > SELECT _FUNC_(array('hello', null ,'world'), ' ', ','); - "hello , world" + hello , world """, since = "2.4.0") case class ArrayJoin( array: Expression, @@ -2236,11 +2236,10 @@ case class ElementAt(left: Expression, right: Expression) extends GetMapValueUti examples = """ Examples: > SELECT _FUNC_('Spark', 'SQL'); - "SparkSQL" + SparkSQL > SELECT _FUNC_(array(1, 2, 3), array(4, 5), array(6)); - [1, 2, 3, 4, 5, 6] - """, - note = "Concat logic for arrays is available since 2.4.0.") + | [1,2,3,4,5,6] + """) case class Concat(children: Seq[Expression]) extends ComplexTypeMergingExpression { private def allowedTypes: Seq[AbstractDataType] = Seq(StringType, BinaryType, ArrayType) @@ -2428,8 +2427,8 @@ case class Concat(children: Seq[Expression]) extends ComplexTypeMergingExpressio usage = "_FUNC_(arrayOfArrays) - Transforms an array of arrays into a single array.", examples = """ Examples: - > SELECT _FUNC_(array(array(1, 2), array(3, 4))); - [1, 2, 3, 4] + > SELECT _FUNC_(array(array(1, 2), array(3, 4)); + [1,2,3,4] """, since = "2.4.0") case class Flatten(child: Expression) extends UnaryExpression { @@ -2935,7 +2934,7 @@ object Sequence { examples = """ Examples: > SELECT _FUNC_('123', 2); - ["123", "123"] + ['123', '123'] """, since = "2.4.0") case class ArrayRepeat(left: Expression, right: Expression) @@ -3056,7 +3055,7 @@ case class ArrayRepeat(left: Expression, right: Expression) examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3, null, 3), 3); - [1, 2, null] + [1,2,null] """, since = "2.4.0") case class ArrayRemove(left: Expression, right: Expression) extends BinaryExpression with ImplicitCastInputTypes { @@ -3246,7 +3245,7 @@ trait ArraySetLike { examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3, null, 3)); - [1, 2, 3, null] + [1,2,3,null] """, since = "2.4.0") case class ArrayDistinct(child: Expression) extends UnaryExpression with ArraySetLike with ExpectsInputTypes { @@ -3422,7 +3421,7 @@ object ArrayBinaryLike { examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), array(1, 3, 5)); - [1, 2, 3, 5] + array(1, 2, 3, 5) """, since = "2.4.0") case class ArrayUnion(left: Expression, right: Expression) extends ArrayBinaryLike @@ -3633,7 +3632,7 @@ object ArrayUnion { examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), array(1, 3, 5)); - [1, 3] + array(1, 3) """, since = "2.4.0") case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBinaryLike @@ -3874,7 +3873,7 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), array(1, 3, 5)); - [2] + array(2) """, since = "2.4.0") case class ArrayExcept(left: Expression, right: Expression) extends ArrayBinaryLike http://git-wip-us.apache.org/repos/asf/spark/blob/be454a7c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala ---------------------------------------------------------------------- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala index 117fa3e..aba9c6c 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala @@ -248,8 +248,8 @@ case class CreateMap(children: Seq[Expression]) extends Expression { in keys should not be null""", examples = """ Examples: - > SELECT _FUNC_(array(1.0, 3.0), array('2', '4')); - [1.0 -> "2", 3.0 -> "4"] + > SELECT _FUNC_([1.0, 3.0], ['2', '4']); + {1.0:"2",3.0:"4"} """, since = "2.4.0") case class MapFromArrays(left: Expression, right: Expression) extends BinaryExpression with ExpectsInputTypes { http://git-wip-us.apache.org/repos/asf/spark/blob/be454a7c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---------------------------------------------------------------------- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala index 3ef2ec0..2bb6b20 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala @@ -209,9 +209,9 @@ trait MapBasedSimpleHigherOrderFunction extends SimpleHigherOrderFunction { examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), x -> x + 1); - [2, 3, 4] + array(2, 3, 4) > SELECT _FUNC_(array(1, 2, 3), (x, i) -> x + i); - [1, 3, 5] + array(1, 3, 5) """, since = "2.4.0") case class ArrayTransform( @@ -318,7 +318,7 @@ case class MapFilter( examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), x -> x % 2 == 1); - [1, 3] + array(1, 3) """, since = "2.4.0") case class ArrayFilter( @@ -499,10 +499,10 @@ case class ArrayAggregate( usage = "_FUNC_(expr, func) - Transforms elements in a map using the function.", examples = """ Examples: - > SELECT _FUNC_(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + 1); - [2 -> 1, 3 -> 2, 4 -> 3] - > SELECT _FUNC_(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v); - [2 -> 1, 4 -> 2, 6 -> 3] + > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + 1); + map(array(2, 3, 4), array(1, 2, 3)) + > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v); + map(array(2, 4, 6), array(1, 2, 3)) """, since = "2.4.0") case class TransformKeys( @@ -549,10 +549,10 @@ case class TransformKeys( usage = "_FUNC_(expr, func) - Transforms values in the map using the function.", examples = """ Examples: - > SELECT _FUNC_(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> v + 1); - [1 -> 2, 2 -> 3, 3 -> 4] - > SELECT _FUNC_(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v); - [1 -> 2, 2 -> 4, 3 -> 6] + > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3)), (k, v) -> v + 1); + map(array(1, 2, 3), array(2, 3, 4)) + > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v); + map(array(1, 2, 3), array(2, 4, 6)) """, since = "2.4.0") case class TransformValues( @@ -603,7 +603,7 @@ case class TransformValues( examples = """ Examples: > SELECT _FUNC_(map(1, 'a', 2, 'b'), map(1, 'x', 2, 'y'), (k, v1, v2) -> concat(v1, v2)); - [1 -> "ax", 2 -> "by"] + {1:"ax",2:"by"} """, since = "2.4.0") case class MapZipWith(left: Expression, right: Expression, function: Expression) @@ -777,11 +777,11 @@ case class MapZipWith(left: Expression, right: Expression, function: Expression) examples = """ Examples: > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x)); - [["a", 1], ["b", 2], ["c", 3]] - > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y); - [4, 6] + array(('a', 1), ('b', 2), ('c', 3)) + > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y)); + array(4, 6) > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y)); - ["ad", "be", "cf"] + array('ad', 'be', 'cf') """, since = "2.4.0") // scalastyle:on line.size.limit --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org