equal_null function

Returns true if expr1 equals expr2 or both expressions are NULL, or false otherwise.

Since: Databricks Runtime 11.1

Syntax

equal_null ( expr1, expr2 )

Arguments

  • expr1: An expression of any comparable type.

  • expr2: An expression sharing a least common type with expr1.

Returns

A BOOLEAN.

This function differs from = (eq sign) operator, by treating NULL as a comparable value.

Examples

> SELECT equal_null(2, 2);
 true

> SELECT equal_null(2, 1);
 false

> SELECT equal_null(NULL, 1);
 false

> SELECT NULL == 1;
 NULL

> SELECT equal_null(NULL, NULL);
 true

> SELECT NULL == NULL;
 NULL