Nullable component values

sxs stores observations in ClickHouse, where every component becomes a column. Whether that column can hold a NULL is decided per component — and getting it right matters, because nullable columns are both restricted and expensive.

Principle

ClickHouse imposes two constraints that shape the mapping:

  1. Nullable is not allowed inside Array types — array elements cannot be Nullable.
  2. Nullable columns cost extra storage and slow down scans.

So sxs makes a column nullable only when it must, based on the component type and — for a few types — on whether the loaded data actually contains empty/null values. That last part is computed at load time: when data is ingested, sxs looks at each component's values and records hasNull (a blank or missing value counts as null) and count.

ComponentColumn in ClickHouseCan hold NULL
MeasureNullable(T)yes
DimensionT (LowCardinality(String) for small enums)no
Time dimensionLowCardinality(String) (or String)no
String attributeLowCardinality(String) (small enums) or Stringno — a null is stored as ''
Numeric attribute (Int32, Decimal)Nullable(T)yes
DateTime attributeT or Nullable(T)only if the data has nulls
Boolean / other attributeT or Nullable(T)only if the data has nulls
Array attributeArray(T) (multilingual: Array(Json(...)))no
Multilingual attributeJson(...) — Nullable(Json(...)) unless mandatoryno when mandatory

Mandatory components are always NOT NULL.

What it means for your data

  • Measures can be null — a missing observation value is stored as NULL.
  • Dimensions and the time dimension are never null — they are part of the observation key and must be present.
  • Strings never store NULL: a missing or empty string is stored as ''. Reading it back gives an empty value, not null.
  • Numeric attributes are always nullable, because a number has no natural "empty" representation.
  • Arrays never contain NULLs (ClickHouse forbids it).
  • Mandatory components reject nulls: loading a blank value for a mandatory component fails with Invalid null value for mandatory component.

See also