IS NOT NULL

All functions > COMPARISON > IS NOT NULL

Returns TRUE if the expression does NOT evaluate to NULL.

Syntax

expr IS NOT NULL [:: type]

Function form

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

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

Notes

  • Opposite of IS NULL
  • Only reliable way to test for non-NULL values
  • Using != 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
  • Never returns NULL itself - always Returns TRUE or FALSE

Examples

IS NOT NULL — detection

FeatureQL
RETURN
    -- Non-NULL string
    f1 := 'x' IS NOT NULL::VARCHAR,
    -- NULL is not non-NULL
    f2 := NULL::VARCHAR IS NOT NULL::VARCHAR
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

IS NOT NULL — composite values

FeatureQL
RETURN
    -- Non-NULL array
    f1 := ARRAY(1, 2) IS NOT NULL::ARRAY<BIGINT>
;
Result
f1 BOOLEAN
true

IS NOT NULL — contrast with !=

FeatureQL
RETURN
    -- `!=` does not behave like IS NOT NULL
    f1 := NULL::BIGINT != NULL::BIGINT
;
Result
f1 BOOLEAN
NULL

IS_NOT_NULL — functional call (second arg is TYPE '…')

FeatureQL
RETURN
    -- Non-NULL string
    f1 := IS_NOT_NULL('x', TYPE 'VARCHAR'),
    -- NULL is not non-NULL
    f2 := IS_NOT_NULL(NULL::BIGINT, TYPE 'BIGINT')
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

IS_NOT_NULL — chained

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