Skip to main content

Module schema

Module schema 

Source
Expand description

Schema registry with schema-on-write and additive evolution.

The schema registry tracks the column definitions for each measurement. Schemas are created automatically on first write and evolve additively: new fields/tags are added automatically, but type changes are rejected.

§Schema Evolution Strategy

Chronix uses a schema-on-write approach to schema evolution:

  • Automatic creation: The first write to a measurement creates the schema with the timestamp column plus all tags and fields from that point.
  • Additive evolution: Subsequent writes may introduce new tag or field columns. These are appended to the schema automatically — no DDL statement is required.
  • Type safety: If a field name already exists with a different type, the write is rejected with SchemaError::TypeConflict.
  • Durability: the catalog manifest is the only durable record of a schema; the database persists every action register_batch returns before it writes the data that needs it
  • Query-time safety: Queries that reference a column not present in older segments return zero rows for those segments (no panic).

§Current Limitations

  • No column removal: Once a tag or field is added, it cannot be dropped. Obsolete columns simply receive null values in new writes.
  • No column rename: Renaming requires writing a migration that copies data from the old column to a new one and stops writing the old name.
  • No type change: A field’s type is immutable once established. To change a field from i64 to f64, create a new field name.
  • No column reorder: Columns are appended in arrival order.

Structs§

ColumnDef
A column definition within a measurement schema.
MeasurementSchema
Schema for a single measurement (table).
SchemaRegistry
Thread-safe, in-memory schema registry.

Enums§

ColumnRole
The role of a column within a measurement.
ColumnType
The data type of a column.
SchemaAction
A schema action that can be applied to the registry.