You are viewing documentation about an older version (1.13.0). View latest version

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