适用于: Databricks SQL
Databricks Runtime
对于非空操作数,返回与 EQUAL(=)
相同的结果,但如果两个操作数均为 true
,则返回 NULL
;如果其中一个操作数为 false
,则返回 NULL
。 此运算符是 expr1 is not distinct from expr2
的同义词。
语法
expr1 <=> expr2
参数
返回
一个布尔值。
示例
> SELECT 2 <=> 2;
true
> SELECT 1 <=> '1';
true
> SELECT true <=> NULL;
false
> SELECT NULL <=> NULL;
true
-- By default string comparisons are trailing space sensitive
-- This can be overridden by using the COLLATE clause
> SELECT 'hello' <=> 'hello ' AS default,
'hello' <=> 'hello ' COLLATE UTF8_BINARY AS utf8_binary,
'hello' <=> 'hello ' COLLATE UTF8_BINARY_RTRIM AS rtrim;
default utf8_binary rtrim
------- ----------- -----
false false true
-- String comparisons are trailing space sensitive by default
-- Use the COLLATE clause to override the default
> SELECT 'world ' <=> 'world ' AS default,
'world ' <=> 'world ' COLLATE UTF8_BINARY AS utf8_binary,
'world ' <=> 'world ' COLLATE UTF8_BINARY_RTRIM AS rtrim;
default utf8_binary rtrim
------- ----------- -----
false false true