infoankitp commented on code in PR #38865:
URL: https://github.com/apache/spark/pull/38865#discussion_r1038747836


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4600,3 +4600,69 @@ case class ArrayExcept(left: Expression, right: 
Expression) extends ArrayBinaryL
   override protected def withNewChildrenInternal(
     newLeft: Expression, newRight: Expression): ArrayExcept = copy(left = 
newLeft, right = newRight)
 }
+
+/**
+ * Given an array, and another element append the element at the end of the 
array.
+ */
+@ExpressionDescription(
+  usage = "_FUNC_(expr, expr) - Prepend the element",
+  examples = """
+    Examples:
+      > SELECT _FUNC_(array('b', 'd', 'c', 'a'), array(1, 2, 3, 4));
+
+  """,
+  since = "3.4.0",
+  group = "collection_funcs")
+case class ArrayAppend(left: Expression, right: Expression)
+    extends BinaryExpression
+    with ImplicitCastInputTypes {
+  override def prettyName: String = "array_append"
+  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, AnyDataType)
+
+  override def checkInputDataTypes(): TypeCheckResult = {
+    (left.dataType, right.dataType) match {
+      case (ArrayType(e1, _), (e2)) if e1.sameType(e2) =>
+        TypeCheckResult.TypeCheckSuccess
+      case _ =>

Review Comment:
   Documenting the behaviour of snowflake for this function in different 
scenarios
   ```
   select array_append(array_construct(1, 2, 3), 'HELLO');
   -- [ 1, 2, 3, "HELLO" ]
   
   
   select array_append(array_construct(1, 2, 3), NULL);
   -- [1,2,3,undefined]
   
   
   select array_append(NULL, 'a');
   -- null
   
   select array_append(NULL, NULL);
   -- null 
   ```
   So, if the array is null, we don't create an array and return null directly 
while if the element is null we just insert it directly without checking if it 
is null.
   
   As of now I think the function is Null Intolerant, with any null value it 
will return null. Need to override this behaviour. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to