is true 运算符

适用于:check marked yes Databricks SQL check marked yes 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 错误。

如果 exprNULL,则结果为 false

如果指定了 not,则此运算符在 exprtrueNULL 时返回 true,否则返回 false

如果未指定 not,则此运算符在 exprfalse 时返回 true,否则返回 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