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

pulse api facet

Audience: CLI users enumerating distinct values for a single field — a cheap probe for “what are the regions in this cohort?” without building a full filter — or, in rich mode, a multi-field summary of counts, null tallies, percentiles, histograms, and additive contribution counts.

pulse api facet has two modes:

  • Simple mode (--input PATH --field NAME) returns the distinct values of one field. Categorical fields read the dictionary directly (no record scan); non-categorical fields scan records.
  • Rich mode (any of --request, multiple --field, --top-k, --percentile, --histogram, --additive, --labels) returns a FacetResult covering every named field — counts, null tallies, optional percentiles and histograms over numerics, and optional additive contribution counts. Prefer rich mode over repeated simple calls when summarising more than one field.

LLM agents using MCP: see the pulse_facet MCP tool for simple mode and pulse_facet_schema for rich mode.

Synopsis

pulse api facet --input PATH --field NAME [--json]
                [--request FILE]
                [--field NAME ...] [--top-k N]
                [--percentile P ...] [--histogram]
                [--histogram-bins N] [--histogram-min X] [--histogram-max X]
                [--additive FIELD ...] [--labels FIELD=TABLE[:replace|augment]]
                [--echo-request]

Flags

Each flag’s type, default and help text is in the Command & flag reference. With --request, flags layer on top of the FacetRequest file; --input replaces its cohort (filename and data_dir). --histogram needs --histogram-min and --histogram-max. --labels takes the export binding (an integer-coded field in augment mode only).

Mode dispatch: simple mode runs when exactly one --field is passed without any rich-mode flag. Any other combination switches to rich mode and calls FacetSchema.

Output (text mode)

One value per line, unsorted — dictionary order for a categorical field, first-seen record order otherwise:

south
north
east
west

Output (--json)

{
  "format_version": "1.1",
  "data": ["south", "north", "east", "west"],
  "errors": [],
  "warnings": []
}

Performance notes

Field typeBehaviour
categorical_u8 / _u16 / _u32Read directly from the schema’s inline dictionary; O(distinct values), no record scan
Non-categoricalFull scan; distinct values in first-seen order

For columns with very high cardinality on the non-categorical path, expect memory proportional to distinct value count.

Exit codes

CodeMeaning
0Success (warnings allowed)
1Any coded error (missing cohort, unknown field, unknown request key, …) — in the envelope’s errors under --json
2Usage error (unknown flag, malformed value, missing required flag); no envelope

See Exit status: under --json a fatal error is the envelope’s errors (exit 1); warnings alone exit 0.

Examples

# Read categorical dictionary
pulse api facet --input sales.pulse --field region

# JSON envelope
pulse api facet --input sales.pulse --field region --json

# Pipe into another command
for r in $(pulse api facet --input sales.pulse --field region); do
    echo "Region: $r"
done