IS NULL

All functions > COMPARISON > IS NULL

Returns TRUE if the expression evaluates to NULL.

Syntax

expr IS NULL [:: type]

Function form

Returns: TRUE or FALSE; these predicates do not return NULL themselves

IS_NULL(expr: T) → BOOLEAN
sql
ParameterTypeRequiredDescription
exprTYesExpression that may be NULL

Notes

  • Only reliable way to test for NULL values
  • Using = NULL or != NULL always returns NULL, not TRUE/FALSE
  • Works with any data type; optional ::T after the keywords disambiguates the expression when its type would otherwise be unclear (for example EMPTY from an unmatched RELATED); when ::T is present it must match the expression type (including ARRAY and ROW)
  • Never returns NULL itself - always Returns TRUE or FALSE

Examples

IS NULL — detection

FeatureQL
RETURN
    -- Typed NULL
    f1 := NULL::BIGINT IS NULL::BIGINT,
    -- Non-NULL literal
    f2 := 1 IS NULL::BIGINT
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

IS NULL — composite values

FeatureQL
RETURN
    -- Typed NULL array
    f1 := NULL::ARRAY<BIGINT> IS NULL::ARRAY<BIGINT>,
    -- Non-NULL array
    f2 := ARRAY(1, 2) IS NULL::ARRAY<BIGINT>
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

IS NULL — contrast with =

FeatureQL
RETURN
    -- `=` cannot test NULL equality
    f1 := NULL::BIGINT = NULL::BIGINT
;
Result
f1 BOOLEAN
NULL

IS_NULL — functional call (second arg is TYPE '…', not a bare type name)

FeatureQL
RETURN
    -- `TYPE 'T'` supplies the predicate type; it must match the expression type
    f1 := IS_NULL(NULL::BIGINT, TYPE 'BIGINT'),
    -- Non-NULL value
    f2 := IS_NULL(1::BIGINT, TYPE 'BIGINT')
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

IS_NULL — chained

FeatureQL
RETURN
    -- Dot form: receiver is the expression under test
    f1 := (NULL::BIGINT).IS_NULL(TYPE 'BIGINT'),
    -- Same semantics as the prefix call
    f2 := (1::BIGINT).IS_NULL(TYPE 'BIGINT')
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse