is true 运算符

适用于:勾选“是” Databricks SQL 勾选“是” Databricks Runtime

测试 expr 是否为 true。

语法

expr is [not] true

参数

  • expr:布尔或字符串表达式。

返回

一个布尔值。

如果 expr 是不区分大小写的值 't'、'true'、'y'、'yes' 或 '1' 的字符串,则它被解释为布尔值 true。 如果值为 'f'、'false'、'n'、'no' 或 '0',则它被解释为布尔值 false。

任何其他非 NULL 字符串都会导致 CAST_INVALID_INPUT 错误。

如果 expr 为 NULL,则结果为 false。

如果指定了 not,则此运算符在 true 为 expr 或 true 时返回 NULL,否则返回 false。

如果未指定 not,则此运算符在 true 为 expr 时返回 false,否则返回 false。

示例

> SELECT true is true;
 true

> SELECT 't' is true;
 true

> SELECT false is true;
 false

> SELECT NULL is true;
 false

> SELECT 'valid' is true;
 Error: CAST_INVALID_INPUT

> SELECT true is not true;
 false

> SELECT 't' is not true;
 false

> SELECT false is not true;
 true

> SELECT NULL is not true;
 true