snowflake.snowpark.functions.coalesce¶
- snowflake.snowpark.functions.coalesce(*e: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L1669-L1689)¶
Returns the first non-NULL expression among its arguments, or NULL if all its arguments are NULL.
Example:
>>> df = session.create_dataframe([[1, 2, 3], [None, 2, 3], [None, None, 3], [None, None, None]], schema=['a', 'b', 'c']) >>> df.select(df.a, df.b, df.c, coalesce(df.a, df.b, df.c).as_("COALESCE")).show() ----------------------------------- |"A" |"B" |"C" |"COALESCE" | ----------------------------------- |1 |2 |3 |1 | |NULL |2 |3 |2 | |NULL |NULL |3 |3 | |NULL |NULL |NULL |NULL | -----------------------------------