snowflake.snowpark.functions.array_prepend

snowflake.snowpark.functions.array_prepend(array: Union[Column, str], element: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L6627-L6656)

Returns an ARRAY containing the new element as well as all elements from the source ARRAY. The new element is positioned at the beginning of the ARRAY.

Parameters:
  • ARRAY. (array Column containing the source) –

  • prepended. (element Column containing the element to be) –

Example::
>>> from snowflake.snowpark import Row
>>> df = session.create_dataframe([Row(a=[1, 2, 3])])
>>> df.select(array_prepend("a", lit(4)).alias("result")).show()
------------
|"RESULT"  |
------------
|[         |
|  4,      |
|  1,      |
|  2,      |
|  3       |
|]         |
------------
Copy
Language: English