snowflake.snowpark.functions.array_compact¶
- snowflake.snowpark.functions.array_compact(array: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L5262-L5285)¶
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 |] | |] | | -------------------------