Field Types
Audience: anyone designing a cohort schema, decoding a .pulse
file by hand, or trying to understand which type to pick for a column.
Every field type has a fixed type byte, a record width and
well-defined semantics. The registry is
encoding/field_type.go
— the FieldType const block gives the byte values (iota order),
ByteSize() the widths and String() the names below. For the live
list at runtime, read cohort_types out of pulse --json
rather than counting rows in this page.
LLM agents using MCP: see the
cohort-schema-designskill viapulse_skills_getfor the same matrix plus “which type to pick”, andtype-<name>(e.g.type-set-u256) for one type in depth.
Nullability is orthogonal to type
There are no nullable_* types. Any field of any type may be
marked nullable (encoding.Field.Nullable), which sets the schema’s
per-field nullable flag byte and enrols the field in the per-record
null bitmap described in Record Layout.
Nullability never changes a field’s type byte, its width, or the
operator the engine infers for it.
The catalog
Type bytes are the FieldType iota order. Note that it is not
grouped by family — datetime (17) and the two wide set rungs (18, 19)
and the two vector types (20, 21) were appended after the original block, and appending is the only way
to add a type without invalidating every existing file.
| Type | Byte | ByteSize | Notes |
|---|---|---|---|
u8 | 0 | 1 | Unsigned 8-bit integer |
u16 | 1 | 2 | Unsigned 16-bit integer |
u32 | 2 | 4 | Unsigned 32-bit integer |
u64 | 3 | 8 | Unsigned 64-bit integer |
f32 | 4 | 4 | 32-bit IEEE 754 float |
f64 | 5 | 8 | 64-bit IEEE 754 float |
u4 | 6 | 0 | Bit-packed 4-bit unsigned (0–15); takes one record byte |
date | 7 | 4 | Epoch DAYS as signed int32 |
packed_bool | 8 | 0 | Bit-packed boolean; takes one record byte |
categorical_u8 | 9 | 1 | Dictionary-backed single value; ≤ 256 entries |
categorical_u16 | 10 | 2 | ≤ 65,536 entries |
categorical_u32 | 11 | 4 | ≤ 4,294,967,295 entries |
decimal128 | 12 | 16 | Fixed-point exact decimal; per-field (precision, scale), both ≤ 38 |
set_u8 | 13 | 1 | Multi-select bitmask over an inline dictionary of ≤ 8 labels |
set_u16 | 14 | 2 | ≤ 16 labels |
set_u32 | 15 | 4 | ≤ 32 labels |
set_u64 | 16 | 8 | ≤ 64 labels |
datetime | 17 | 8 | Epoch SECONDS as signed int64 |
set_u128 | 18 | 16 | ≤ 128 labels; two little-endian 64-bit words, words[0] = bits 0–63 |
set_u256 | 19 | 32 | ≤ 256 labels; four little-endian words. Widest set rung — a hard ceiling |
vec_f32 | 20 | 0 (4 × dim) | Fixed-dim vector of float32, dim 2..1024. Width is Schema.FieldWidth, not ByteSize() |
vec_f64 | 21 | 0 (8 × dim) | Fixed-dim vector of float64, dim 2..1024 |
Type families
Plain integers and floats
u8, u16, u32, u64, f32, f64. Standard little-endian
encoding, full range, no in-band null sentinel. Mark the field nullable
if the column carries missing values.
Bit-packed types
u4 (a 4-bit unsigned) and packed_bool (one bit) both report
ByteSize() == 0, yet each still occupies one whole byte of the record;
the schema’s BitPosition locates the value inside that byte. Packed
fields never share a byte. Size a field with Schema.FieldWidth, never
ByteSize(). See Record Layout → Bit-packing.
Temporal types
date is a signed (two’s-complement int32) count of days since the
Unix epoch. datetime is a signed (two’s-complement int64) count of
seconds since the same epoch. Pre-1970 values are negative and
supported end to end; encoding.DateDays / encoding.DateTimeSeconds
interpret a raw ReadFieldValue word.
They are never interchangeable: swapping them rescales every value by
86,400. Everything downstream of the operator boundary speaks epoch
days only, so a datetime column is day-truncated exactly once there
(encoding.DateTimeToDay, toward the past, naive UTC).
Categoricals
categorical_u8, categorical_u16, categorical_u32 store a single
dictionary ID per row and carry the string-to-ID mapping inline as a
dictionary block immediately after the field’s schema entry. Pick the
smallest variant that fits your cardinality (import inference does this
for you). See Dictionary Blocks.
Sets (multi-select bitmasks)
set_u8, set_u16, set_u32, set_u64, set_u128, set_u256 carry
the same inline dictionary block as a categorical, but the on-wire
payload is a fixed-width bitmask: bit i set means dictionary entry
i is selected. One row can select any number of labels, which is what
makes these the landing type for an SPSS multiple-dichotomy battery.
- Inference picks the smallest rung that fits the option count; a column with more than 256 options has no set type at all and stays as its constituent columns.
- An empty mask is a valid value meaning “answered, selected nothing” — it is NOT null, and the two must stay distinct because “ticked none of these” and “skipped the question” give different denominators.
- The wide rungs (
set_u128,set_u256) exceed theuint64value API:ReadFieldValue/WriteFieldValuerefuse them withENCODING_TYPE_MISMATCHrather than truncating to the low 64 bits (FieldType.IsWideSet()). Wide masks travel asencoding.SetMask. - Operators that read a set name labels, never bits. Filter with
FILTER_SET_CONTAINS_ANY,FILTER_SET_CONTAINS_ALL,FILTER_SET_CONTAINS_NONEorFILTER_SET_EQUALS; group by the whole mask (GROUP_SET_VALUE) or once per selected label (GROUP_SET_PER_ELEMENT); deriveATTR_SET_HAS(is one label selected) orATTR_SET_POPCOUNT(how many are); aggregate withAGG_SET_FREQUENCY(rows per label),AGG_SET_UNION,AGG_SET_INTERSECTION,AGG_SET_CARDINALITY_SUM,AGG_SET_CARDINALITY_AVG(mean selections per row) orAGG_SET_DISTINCT_VALUES(distinct combinations).
Decimal128
decimal128 is a 16-byte fixed-point decimal. Each field carries a
per-field (precision, scale) pair written into the schema after the
description; both top out at 38 (PULSE_DECIMAL_OVERFLOW,
PULSE_DECIMAL_PRECISION_LOSS).
Use it for currency and any other column where IEEE-754 rounding is
not acceptable. See the financial-cohorts skill for full semantics
including banker’s rounding and divide-by-zero policy. decimal128
nulls ride the bitmap only — there is no in-band sentinel.
Vector fields
vec_f32 / vec_f64 store dim little-endian IEEE-754 elements per
row, element 0 first. The dim is not in the type byte: it rides the
schema’s VECTORS section (extension-block tag 2, always REQUIRED), so
a vector’s width is element size × dim, a property of the field in its
schema. That is why ByteSize() is 0 and every stride, offset and skip
sums encoding.Schema.FieldWidth instead. Any vector makes the cohort
format 0x02; an older binary refuses it loudly (unknown type byte, or
unknown REQUIRED section), never mis-strides it.
The VECTORS section lists, per vector field in strictly ascending field
index: u16 field_index, u16 dim, u8 flags (bit 0 labels, bit 1
kind, bit 2 scale range), then the optional kind byte, f64 scale_min /
f64 scale_max, and dim length-prefixed UTF-8 element labels. Dim
outside 2..1024, a missing entry for a vector field, a label count other
than 0 or dim, or scale_min >= scale_max is ENCODING_INVALID, on
write and on read.
A null vector is a zeroed stride plus its null-bitmap bit; a NaN element
is a stored value, not a null. The uint64 value API refuses both types
(ENCODING_TYPE_MISMATCH); use encoding.ReadVector / WriteVector,
which take the dim explicitly. A vec_f32 finite value beyond ±3.4e38
is refused on write rather than stored as ±Inf. Import, naming in
requests and export: the vector-fields skill and the --vector
section of the CLI flags.
Unknown type bytes
The schema reader rejects unknown FieldType bytes at parse time
with ENCODING_INVALID. This is the same fail-loud strategy as the
header version check: a file written by a future binary that
introduced a new type fails immediately at schema parse, not later
during row decode where the corruption could go unnoticed.
What you can do with each type
| Concern | Source |
|---|---|
| Which aggregators are meaningful on which types | skills/aggregation-design.md (LLM) / api process (CLI) |
| Per-type depth, one file per type | skills/type-<name>.md (LLM) |
| Vector fields: import, request naming, export | skills/vector-fields.md (LLM) |
| Decimal arithmetic semantics | skills/financial-cohorts.md (LLM) |
| Categorical and set dictionary limits | Dictionary Blocks |
| Multiple-response set import | import spss |