snowflake.snowpark.functions.ifnull

snowflake.snowpark.functions.ifnull(e1: Union[Column, str], e2: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.30.0/snowpark-python/src/snowflake/snowpark/functions.py#L11040-L11053)

If expr1 is NULL, returns expr2, otherwise returns expr1.

Example:

>>> df = session.create_dataframe([("a", "b"), ("c", None), (None, "d"), (None, None)], schema=["e1", "e2"])
>>> df.select(ifnull(df["e1"], df["e2"]).alias("result")).collect()
[Row(RESULT='a'), Row(RESULT='c'), Row(RESULT='d'), Row(RESULT=None)]
Copy
语言: 中文