IS DISTINCT FROM
All functions > COMPARISON > IS DISTINCT FROM
Returns TRUE if two values are distinct, treating NULL values as comparable.
Syntax
expr1 IS DISTINCT FROM expr2
Function form
Returns: Null-safe equality / inequality result
IS_DISTINCT_FROM(expr1: T, expr2: T) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
expr1 | T | Yes | First value |
expr2 | T | Yes | Second value |
Notes
- Null-safe inequality: unlike
!=, NULL is treated as comparable here NULL IS DISTINCT FROM NULLis FALSEvalue IS DISTINCT FROM NULLandNULL IS DISTINCT FROM valueare TRUE when value is not NULL- Operand types must match structurally (including ARRAY/ROW shape and field/element types)
- Opposite of
IS NOT DISTINCT FROM expr1 NOT DISPLAYS AS expr2is an accepted permissive spelling with the same meaning;FORMAT (FIX)rewrites it toIS DISTINCT FROM
See also
Examples
IS DISTINCT FROM
FeatureQL
RETURN
-- Same values
f1 := (1 IS DISTINCT FROM 1),
-- Different values
f2 := (1 IS DISTINCT FROM 2),
-- Both NULL
f3 := (NULL::BIGINT IS DISTINCT FROM NULL::BIGINT),
-- NULL vs non-NULL
f4 := (NULL::BIGINT IS DISTINCT FROM 1),
-- Non-NULL vs NULL
f5 := (1 IS DISTINCT FROM NULL::BIGINT)
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN | f4 BOOLEAN | f5 BOOLEAN |
|---|---|---|---|---|
| false | true | false | true | true |
IS DISTINCT FROM — other types
FeatureQL
RETURN
-- Same doubles
f1 := (1e0 IS DISTINCT FROM 1e0),
-- Both NULL doubles
f2 := (NULL::DOUBLE IS DISTINCT FROM NULL::DOUBLE)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| false | false |
IS DISTINCT FROM — arrays and rows
FeatureQL
RETURN
-- Distinct arrays
f1 := (ARRAY(1, 2) IS DISTINCT FROM ARRAY(1, 3))
;Result
| f1 BOOLEAN |
|---|
| true |
IS_DISTINCT_FROM — functional call
FeatureQL
RETURN
-- `IS_DISTINCT_FROM(expr1, expr2)` matches SQL spelling
f1 := IS_DISTINCT_FROM(1, 2),
-- Same value is not distinct
f2 := IS_DISTINCT_FROM(1, 1)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
IS_DISTINCT_FROM — chained
FeatureQL
RETURN
-- Receiver is the left-hand operand
f1 := (1).IS_DISTINCT_FROM(2),
-- Same semantics as the prefix call
f2 := (1).IS_DISTINCT_FROM(1)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |