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

snowflake.snowpark.functions.array_min

snowflake.snowpark.functions.array_min(array: Union[Column, str]) Column[source]

Returns smallest defined non-NULL element in the input array. If the input array is empty, or there is no defined element in the input array, then the function returns NULL.

Make sure BCR 2023_05 Bundle is enabled before using this function.

Parameters:

array – the input array

Returns:

a VARIANT containing the smallest defined element in the array, or NULL

Examples::
Behavior with SQL nulls:
>>> df = session.sql("select array_construct(20, 0, null, 10) as A")
>>> df.select(array_min(df.a).as_("min_a")).collect()
[Row(MIN_A='0')]
>>> df = session.sql("select array_construct() as A")
>>> df.select(array_min(df.a).as_("min_a")).collect()
[Row(MIN_A=None)]
>>> df = session.sql("select array_construct(null, null, null) as A")
>>> df.select(array_min(df.a).as_("min_a")).collect()
[Row(MIN_A=None)]
Copy
Behavior with JSON nulls:
>>> df = session.create_dataframe([[[None, None, None]]], schema=["A"])
>>> df.select(array_min(df.a).as_("min_a")).collect()
[Row(MIN_A='null')]
Copy