snowflake.snowpark.functions.array_compact¶

snowflake.snowpark.functions.array_compact(array: Union[Column, str]) → Column[source]¶

Returns a compacted ARRAY with missing and null values removed, effectively converting sparse arrays into dense arrays.

Parameters:

array – Column containing the source ARRAY to be compacted

Example::
>>> from snowflake.snowpark import Row
>>> df = session.create_dataframe([Row(a=[1, None, 3])])
>>> df.select("a", array_compact("a").alias("compacted")).show()
-------------------------
|"A"      |"COMPACTED"  |
-------------------------
|[        |[            |
|  1,     |  1,         |
|  null,  |  3          |
|  3      |]            |
|]        |             |
-------------------------
Copy