Fields
Fields are the columns of a table. Every field has an id, a data type, and
optional Validator instances. Three concrete
field types differ in where the value comes from:
DataField— imported data, with an optional default value.CalculatedField— value computed by aFormula.ComboField— carries both a formula and a stored value; thecalculate_in_optimiserflag decides whether the optimiser evaluates the formula (True) or reads the stored value (False). The opposite mode is used outside optimisation, e.g. when the field is rendered in the UI.
Field hierarchy: Field base + the three concrete field types
(DataField, CalculatedField, ComboField).
A field is a column on a Table. Each field carries an id,
a data type, and an optional set of Validator
instances. Concrete field types differ in where the value comes from — imported
data, a formula, or a hybrid that switches between the two.
- FIELD_BUILD_KEYS: frozenset[str] = frozenset({'@type', 'calculateInOptimiser', 'dataType', 'defaultValue', 'description', 'formula', 'id', 'importFormat', 'nullable', 'orderIndex', 'tableId', 'trackingGroups', 'unique'})
The complete camelCase key vocabulary a field’s
build()can emit, across all three concrete field types. Co-located with the field classes so it is the single source of truth for both the serialiser (the genericBuildablewalk over these attrs) and the field decoder’s unmapped-key guard, which imports it as_KNOWN_KEYS. Fields build via the generic walk rather than a custombuild; this set is pinned to that walk’s actual output bytest_guard_key_setsso it cannot drift.@typeis the discriminator emitted byjson_type_info(); the rest are the camelised public attributes set acrossDataField,CalculatedFieldandComboField.
- class Field(id, table, data_type)[source]
Abstract base for a column on a
Table.Use the concrete subclasses
DataField,CalculatedField, andComboFieldrather than constructingFielddirectly. Every field has anid, an owningtable, and adata_type; optionally anorder_index, adescription, and zero or moreValidatorinstances (at most one perSeverity).- table_id
The owning table’s id.
- data_type
The
BaseDataTypeof this field.
- tracking_groups: list[str] | None
Names of the tracking groups this field belongs to (
Nonewhen untracked).
- set_tracking_groups(groups)[source]
Assign this field to one or more change-tracking groups.
A tracked field requires its table to declare an
id_field. Passing an empty list clears tracking.
- set_order_index(idx)[source]
Set the field’s position within its table (lower values come first).
- Return type:
- add_validator(validator)[source]
Attach a
Validatorto this field.Each field may carry at most one validator per
Severity.- Raises:
ValueError – If a validator with the same severity is already attached.
- Return type:
- get_validation_fields(severity=None)[source]
Return the synthetic validation fields generated for this field’s validators.
- Parameters:
severity (
Severity|None) – When given, return only the validation fields for that severity. WhenNone, return oneValidationFieldsContainerper attached validator, sorted by ascending severity rank.- Return type:
list[ValidationFieldsContainer] |ValidationFieldsContainer|None- Returns:
A single
ValidationFieldsContainer, a list of them, orNoneif no validator matches.
- get_combined_message_field()[source]
Return a single calculated field combining all per-severity messages.
The combined field is a STRING_ARRAY ordered from highest to lowest severity (CRITICAL → ERROR → WARNING → INFO); blank messages are excluded. The field is registered on the table as
{id}__message__combinedon first call and cached for subsequent calls.
- class CalculatedField(id, table, formula)[source]
A field whose value is computed by a
Formula.The field’s data type is taken from the formula. Calculated fields are read-only — their value is recomputed whenever inputs change.
- formula
The formula evaluated to produce this field’s value.
- class OverridableField(id, table, formula, override_field, calculated_field)[source]
The effective field of an overridable trio created by
add_overridable_field(): a calculated field, an override data field, and this field —IFBLANK(override, calculated).Used as an operand it yields the effective value. Builds as a plain calculated field.
- property calculated: CalculatedField
The calculated field holding the computed value.
- property effective: OverridableField
override when present, otherwise calculated.
- Type:
The effective field (this field)
- class DataField(id, table, data_type)[source]
A field populated from imported data or an optional default value.
- import_format: str | None
Import format hint (e.g. a date pattern) applied when parsing input rows.
- nullable: bool
Whether this field accepts null/blank values. Integer, decimal, string and boolean fields default to not nullable; every other type (dates/times, arrays, object references, maps) defaults to nullable.
- set_default_value(value)[source]
Set the default value used when no imported value is present.
- Return type:
- set_import_format(fmt)[source]
Set the import format hint applied when parsing this field on import.
- Return type:
- class ComboField(id, table, formula, calculate_in_optimiser)[source]
A field that switches between data and calculated behaviour.
Combo fields carry a
Formulaand an underlying stored value. Thecalculate_in_optimiserflag chooses which one the optimiser sees:calculate_in_optimiser=True: the optimiser evaluates the formula (treating the field as aCalculatedField), while outside optimisation the stored data value is used.calculate_in_optimiser=False: the optimiser uses the stored data value (treating the field as aDataField), while outside optimisation — for example when the field is rendered in the UI — the formula is evaluated (treating the field as aCalculatedField).
- formula
Formula evaluated when the field is treated as calculated.
- calculate_in_optimiser
Selects whether the optimiser evaluates the formula or reads the stored value. See the class docstring for the full behaviour.
- dependencies()[source]
The reference leaves this field’s formula uses (empty for a string-only formula).
- Return type:
set[Operand]
- set_default_value(value)[source]
Set the default value used when no imported value is present.
- Return type: