HyukjinKwon commented on code in PR #57079:
URL: https://github.com/apache/spark/pull/57079#discussion_r3556885924


##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -20217,17 +20834,21 @@ def array_insert(arr: "ColumnOrName", pos: 
Union["ColumnOrName", int], value: An
     Parameters
     ----------
     arr : :class:`~pyspark.sql.Column` or str
-        name of column containing an array
+        name of column containing an array.
+        A column that evaluates to an array.
     pos : :class:`~pyspark.sql.Column` or str or int
         name of Numeric type column indicating position of insertion
-        (starting at index 1, negative position is a start from the back of 
the array)
+        (starting at index 1, negative position is a start from the back of 
the array).
+        A column of the same type as the array elements.

Review Comment:
   `pos` is the 1-based insertion index, not an array element — `ArrayInsert` 
coerces it to `IntegerType` (`inputTypes` returns `Seq(ArrayType(dt,_), 
IntegerType, dt)`, and `checkInputDataTypes` rejects a non-`IntegerType` `pos` 
with UNEXPECTED_INPUT_TYPE, collectionOperations.scala:5235-5257). The "element 
type" rewording was over-applied here; only the `value` arg below (20845) is 
the element type. The SQL `@ExpressionDescription` correctly keeps `pos` as 
integer (collectionOperations.scala:5208), so this makes PySpark disagree with 
SQL.
   ```suggestion
           A column that evaluates to an integer.
   ```



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