snowflake.snowpark.functions.array_remove¶

snowflake.snowpark.functions.array_remove(array: Union[Column, str], element: Union[Column, None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, NaTType, float64, list, tuple, dict]) → Column[source]¶

Given a source ARRAY, returns an ARRAY with elements of the specified value removed.

Parameters:
  • array – name of column containing array.

  • element – element to be removed from the array. If the element is a VARCHAR, it needs to be casted into VARIANT data type.

Examples::
>>> from snowflake.snowpark.types import VariantType
>>> df = session.create_dataframe([([1, '2', 3.1, 1, 1],)], ['data'])
>>> df.select(array_remove(df.data, 1).alias("objects")).show()
-------------
|"OBJECTS"  |
-------------
|[          |
|  "2",     |
|  3.1      |
|]          |
-------------
Copy
>>> df.select(array_remove(df.data, lit('2').cast(VariantType())).alias("objects")).show()
-------------
|"OBJECTS"  |
-------------
|[          |
|  1,       |
|  3.1,     |
|  1,       |
|  1        |
|]          |
-------------
Copy
>>> df.select(array_remove(df.data, None).alias("objects")).show()
-------------
|"OBJECTS"  |
-------------
|NULL       |
-------------
Copy

See also

  • ARRAY for more details on semi-structured arrays.