yaooqinn commented on a change in pull request #26371: [SPARK-27976][SQL] Add
built-in Array Functions: array_append
URL: https://github.com/apache/spark/pull/26371#discussion_r341890780
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -3928,3 +3928,128 @@ case class ArrayExcept(left: Expression, right:
Expression) extends ArrayBinaryL
override def prettyName: String = "array_except"
}
+
+@ExpressionDescription(
+ usage = """
+ _FUNC_(array, element) - Returns an array of appending an element to the end
of an array
+ """,
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(1, 2, 3), 3);
+ [1,2,3,3]
+ > SELECT _FUNC_(array(1, 2, 3), null);
+ [1,2,3,null]
+ > SELECT _FUNC_(a, e) FROM VALUES (array(1,2), 3), (array(3, 4), null),
(null, 3) tbl(a, e);
+ NULL
+ [1,2,3]
+ [3,4,null]
+ """,
+ since = "3.0.0")
+case class ArrayAppend(left: Expression, right: Expression) extends
BinaryExpression {
Review comment:
Some bugs, also
```sql
spark-sql> select concat(null, array(1));
Error in query: cannot resolve 'concat(CAST(NULL AS STRING), array(1))' due
to data type mismatch: input to function concat should all be the same type,
but it's [string, array<int>]; line 1 pos 7;
'Project [unresolvedalias(concat(cast(null as string), array(1)), None)]
+- OneRowRelation
spark-sql>
```
```
spark-sql> select concat(array(1), array(null));
19/11/04 10:26:33 ERROR SparkSQLDriver: Failed in [select concat(array(1),
array(null))]
scala.MatchError: NullType (of class org.apache.spark.sql.types.NullType$)
at
org.apache.spark.sql.catalyst.expressions.Cast.castToInt(Cast.scala:434)
at
org.apache.spark.sql.catalyst.expressions.Cast.org$apache$spark$sql$catalyst$expressions$Cast$$cast(Cast.scala:622)
at
org.apache.spark.sql.catalyst.expressions.Cast.castArray(Cast.scala:563)
at
org.apache.spark.sql.catalyst.expressions.Cast.org$apache$spark$sql$catalyst$expressions$Cast$$cast(Cast.scala:627)
at
org.apache.spark.sql.catalyst.expressions.Cast.cast$lzycompute(Cast.scala:639)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]