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
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | Expression that may be NULL |
Notes
- Opposite of IS NULL
- Only reliable way to test for non-NULL values
- Using
!= NULLalways returns NULL, not TRUE/FALSE - Works with any data type; optional
::Tafter the keywords disambiguates the expression when its type would otherwise be unclear (for exampleEMPTYfrom an unmatchedRELATED); when::Tis 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 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
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 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
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 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |