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 aFacetResultcovering 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_facetMCP tool for simple mode andpulse_facet_schemafor 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 type | Behaviour |
|---|---|
categorical_u8 / _u16 / _u32 | Read directly from the schema’s inline dictionary; O(distinct values), no record scan |
| Non-categorical | Full 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
| Code | Meaning |
|---|---|
| 0 | Success (warnings allowed) |
| 1 | Any coded error (missing cohort, unknown field, unknown request key, …) — in the envelope’s errors under --json |
| 2 | Usage 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
Related
pulse api sample— raw rows preview- Format: Dictionary Blocks — how categorical dictionaries are encoded
- Library: pulse.Facet