Skip to main content

equal_null

Returns same result as the EQUAL(=) operator for non-null operands, but returns true if both are null, false if one of them is null.

For the corresponding Databricks SQL function, see equal_null function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.equal_null(col1=<col1>, col2=<col2>)

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column or str

The first column to compare.

col2

pyspark.sql.Column or str

The second column to compare.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
df.select('*', dbf.equal_null(df.a, df.b)).show()
Output
+----+----+----------------+
| a| b|equal_null(a, b)|
+----+----+----------------+
|NULL|NULL| true|
| 1| 9| false|
+----+----+----------------+