Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Label, Range and Lookup Tables

Audience: embedders giving requests named reference data: display names for codes, named bands, keyed rates.

TableHoldsA request uses it through
Label (pulse.LabelTable)key → display stringa labels binding (display only: filters and group keys still see the raw value), pulse_label_resolve for reverse search
Range (pulse.RangeTable)named {label, start, end} bands, all dates or all numbersparams.table on GROUP_DATE_RANGES, GROUP_NUMERIC_RANGES and FILTER_DATE_RANGES; range_label() in an expression
Lookup (pulse.LookupTable)joined key → numberlookup("table", key…) in an expression

When to use them

Use a table when the same mapping recurs across requests or must stay out of the cohort: a code list that changes without a re-import, score bands shared by every report, a rate grid. Inline ranges or an expression literal is simpler for a one-off.

Registering

Two sources, one name space per kind (a name declared twice is PULSE_EXTENSION_DUPLICATE):

  • In code: Options.Extensions.LabelTables, RangeTables, LookupTables, maps keyed by table name. A label or lookup table takes Rows, or a Lookup func that reads an external store.
  • From a directory: every *.json file in Options.LabelTablesDir, RangeTablesDir or LookupTablesDir (else PULSE_LABEL_TABLES_DIR, PULSE_RANGE_TABLES_DIR, PULSE_LOOKUP_TABLES_DIR) loads at pulse.New, named by its file stem. These directories are read from the OS filesystem, never Options.FS; a missing directory loads nothing, a malformed file fails pulse.New naming the path. Validate a lookup file the way the loader does with pulse.ParseLookupTableFile.
package tables

import "github.com/frankbardon/pulse"

func New(dataDir string) (*pulse.Pulse, error) {
	start, mid := 0.0, 50.0
	return pulse.New(pulse.Options{DataDir: dataDir, Extensions: pulse.Extensions{
		LabelTables: map[string]pulse.LabelTable{
			"region_names": {Rows: map[string]string{"n": "North", "s": "South"}},
		},
		RangeTables: map[string]pulse.RangeTable{
			"score_bands": {NumericRanges: []pulse.NumericRangeSpec{
				{Label: "low", Start: &start, End: &mid},
				{Label: "high", Start: &mid},
			}},
		},
		LookupTables: map[string]pulse.LookupTable{
			"uplift": {Rows: map[string]float64{"North|low": 1.05, "North|high": 1.10}},
		},
	}})
}

Pulse.LabelTables(), RangeTables() and LookupTables() list what an instance carries; agents see the same lists through the pulse_label_tables, pulse_range_tables and pulse_lookup_tables tools (MCP Integration). A feature profile hides each kind with capability:labels, capability:range_tables or capability:lookup_tables.

Where the detail lives