Nullable
Nullable(T) allows a missing value where a typed member would otherwise require a value of type T. It is particularly useful for elements of arrays, tuple fields and map values.
Syntax
Nullable(T)Column and member nullability
Top-level SQL columns permit NULL unless they declare NOT NULL, including columns whose type is written without Nullable. The wrapper is needed to admit NULL inside a native composite value.
For example, Array(UInt8) requires a non-NULL integer at every position, while Array(Nullable(UInt8)) can contain missing elements. Map keys cannot be nullable.
Nullable can wrap supported collections as well as scalar types. Use a column NOT NULL constraint to forbid a missing value at the top level.
Finding NULL
Most comparisons with NULL return NULL, rather than true or false. Use IS NULL or IS NOT NULL to test for a missing value. Use coalesce to supply a fallback. Aggregate functions document whether they skip or retain NULL values.
Usage Example
A nullable array element
SELECT CAST('[1,null,3]' AS Array(Nullable(UInt8)))
FORMAT csv;"[1,null,3]"Testing and replacing NULL
SELECT NULL = NULL,
NULL IS NULL,
coalesce(NULL, 7)
FORMAT csv;\N,1,7See NULL functions for additional operations.