Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns null if col1 equals to col2, or col1 otherwise.
For the corresponding Databricks SQL function, see nullif function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.nullif(col1=<col1>, col2=<col2>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col1 |
pyspark.sql.Column or str |
The first column to check. |
col2 |
pyspark.sql.Column or str |
The column to compare with col1. |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
df.select('*', dbf.nullif(df.a, df.b)).show()
+----+----+------------+
| a| b|nullif(a, b)|
+----+----+------------+
|NULL|NULL| NULL|
| 1| 9| 1|
+----+----+------------+