Skip to content

Forward-Fill & Device Shadow

Storage keeps the sparse truth; reads fill it. A filled value is never written to disk.

Fill policies

Each channel declares one:

Policy Meaning Typical channels
FILL HOLD Last observed value carries forward (LOCF) until it goes stale state, level, speed, temperature
FILL NONE Only an exact-timestamp sample counts; filling would be inventing data events, alarms, button presses

HOLD takes an optional STALENESS <duration> (or INFINITE, the default): once ts − last_sample_ts exceeds it, the held value reads as null — a sensor that went quiet stops pretending.

If no prior value exists, the answer is null regardless of policy.

Row reconstruction

SELECT speed, event FROM t WHERE entity = 'veh-1' AND ts BETWEEN a AND b returns one row per timestamp where any selected channel has a real sample. The other cells are filled per policy:

ts        speed(HOLD)   event(NONE)
10000     50            null          ← speed sampled here
20000     50 (held)     'brake'       ← event sampled here
30000     60            null          ← speed sampled here

Instantaneous state (device shadow)

The shadow is each channel's stream tail:

SELECT * FROM telemetry LATEST ON ts PARTITION BY entity;

One row per entity; each channel at its latest value, ts = the newest of them. Historical state at instant T is the same idea with last value ≤ T per channel — a binary search over ordered streams, not a table scan.