is distinct 运算符

适用于:check marked yes Databricks SQL check marked yes Databricks Runtime

测试参数是否具有不同的值,其中 NULL 被视为可比较值。

语法

expr1 is [not] distinct from expr2

参数

  • expr1:可比较类型的表达式。
  • expr2:一种表达式类型,该表达式与 expr1 共有最不常见类型

返回

一个布尔值。

如果 expr1expr2 都为 NULL,它们将被视为相同。

如果 expr1expr2 中只有一个为 NULL,则表达式将被视为不同。

如果 expr1expr2 都不为 NULL,它们将被视为不同(如果 expr<>expr2)。

示例

> SELECT NULL is distinct from NULL;
 false

> SELECT NULL is distinct from 5;
 true

> SELECT 1 is distinct from 5;
 true

> SELECT NULL is not distinct from 5;
 false