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

snowflake.snowpark.functions.array_max¶

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

Returns largest 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.

Parameters:

array – the input array

Returns:

a VARIANT containing the largest 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_max(df.a).as_("max_a")).collect()
[Row(MAX_A='20')]
>>> df = session.sql("select array_construct() as A")
>>> df.select(array_max(df.a).as_("max_a")).collect()
[Row(MAX_A=None)]
>>> df = session.sql("select array_construct(null, null, null) as A")
>>> df.select(array_max(df.a).as_("max_a")).collect()
[Row(MAX_A=None)]
Copy
Behavior with JSON nulls:
>>> df = session.create_dataframe([[[None, None, None]]], schema=["A"])
>>> df.select(array_max(df.a).as_("max_a")).collect()
[Row(MAX_A='null')]
Copy