IS NOT DISTINCT FROM

All functions > COMPARISON > IS NOT DISTINCT FROM

Returns TRUE if two values are not distinct, treating NULL values as comparable.

Syntax

expr1 IS NOT DISTINCT FROM expr2

Function form

Returns: Null-safe equality / inequality result

IS_NOT_DISTINCT_FROM(expr1: T, expr2: T) → BOOLEAN
sql
ParameterTypeRequiredDescription
expr1TYesFirst value
expr2TYesSecond value

Notes

  • Null-safe equality: unlike =, NULL is treated as comparable here
  • NULL IS NOT DISTINCT FROM NULL is TRUE
  • value IS NOT DISTINCT FROM NULL is FALSE when value is not NULL
  • Nested NULL inside ARRAY/ROW is compared null-safely at every nesting level
  • Operand types must match structurally (including ARRAY/ROW shape and field/element types)
  • Prefer IS NOT DISTINCT FROM over = for null-safe joins and filters; GROUP BY uses the same null-safe equivalence
  • Opposite of IS DISTINCT FROM
  • expr1 DISPLAYS AS expr2 is an accepted permissive spelling with the same meaning; FORMAT (FIX) rewrites it to IS NOT DISTINCT FROM

See also

Examples

IS NOT DISTINCT FROM

FeatureQL
RETURN
    -- Same values
    f1 := (1 IS NOT DISTINCT FROM 1),
    -- Different values
    f2 := (1 IS NOT DISTINCT FROM 2),
    -- Both NULL
    f3 := (NULL::BIGINT IS NOT DISTINCT FROM NULL::BIGINT),
    -- NULL vs non-NULL
    f4 := (NULL::BIGINT IS NOT DISTINCT FROM 1),
    -- Non-NULL vs NULL
    f5 := (1 IS NOT DISTINCT FROM NULL::BIGINT)
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEANf5 BOOLEAN
truefalsetruefalsefalse

IS NOT DISTINCT FROM — other types

FeatureQL
RETURN
    -- Same doubles
    f1 := (1e0 IS NOT DISTINCT FROM 1e0),
    -- Both NULL doubles
    f2 := (NULL::DOUBLE IS NOT DISTINCT FROM NULL::DOUBLE)
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue

IS NOT DISTINCT FROM — arrays and rows

FeatureQL
RETURN
    -- Equal arrays
    f1 := (ARRAY(1, 2) IS NOT DISTINCT FROM ARRAY(1, 2)),
    -- Both NULL arrays
    f2 := (NULL::ARRAY<BIGINT> IS NOT DISTINCT FROM NULL::ARRAY<BIGINT>)
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue

IS_NOT_DISTINCT_FROM — functional call

FeatureQL
RETURN
    -- `IS_NOT_DISTINCT_FROM(expr1, expr2)` matches SQL spelling
    f1 := IS_NOT_DISTINCT_FROM(1, 1),
    -- Both NULL: null-safe equality
    f2 := IS_NOT_DISTINCT_FROM(NULL::BIGINT, NULL::BIGINT)
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue

IS_NOT_DISTINCT_FROM — chained

FeatureQL
RETURN
    -- Receiver is the left-hand operand
    f1 := (1).IS_NOT_DISTINCT_FROM(1),
    -- Same semantics as the prefix call
    f2 := (NULL::BIGINT).IS_NOT_DISTINCT_FROM(NULL::BIGINT)
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue