snowflake.snowpark.functions.nullif¶
- snowflake.snowpark.functions.nullif(expr1: Union[snowflake.snowpark.column.Column, str], expr2: Union[snowflake.snowpark.column.Column, str]) Column[source]¶
Returns None if expr1 is equal to expr2, otherwise returns expr1.
- Parameters:
expr1 (ColumnOrName) – The first expression to compare.
expr2 (ColumnOrName) – The second expression to compare.
- Returns:
None if expr1 is equal to expr2, otherwise expr1.
- Return type:
Example:
>>> df = session.create_dataframe([[0, 0], [0, 1], [1, 0], [1, 1], [None, 0]], schema=["a", "b"]) >>> df.select(nullif(df["a"], df["b"]).alias("result")).collect() [Row(RESULT=None), Row(RESULT=0), Row(RESULT=1), Row(RESULT=None), Row(RESULT=None)]