Skip to content

Operations reference

Each operation is a top-level key in the query document. Use [] for a scalar reduction over all selected elements, or an axis index / list for partial reductions.

Every example shows JSON and TOML. Population var / std use ddof = 0. norm_l2 is √(sum of squares). Integer wire dtypes promote to f64 in aggregate fields.

Tier-A/B — streaming fold

Fast on large selections — no full tensor in RAM.

Basic reductions

KeyScalar fieldPartial fields
sumoperation_sumoperation_reduced_sum, operation_reduced_shape
meanoperation_meanoperation_reduced_mean, …
minoperation_minoperation_reduced_min, …
maxoperation_maxoperation_reduced_max, …
countoperation_element_countoperation_reduced_count, …
varoperation_varoperation_reduced_var, …
stdoperation_stdoperation_reduced_std, …
productoperation_productoperation_reduced_product, …
norm_l1operation_norm_l1operation_reduced_norm_l1, …
norm_l2operation_norm_l2operation_reduced_norm_l2, …

Scalar mean:

json
{ "dataset": "temperature", "mean": [] }
toml
dataset = "temperature"
mean = []

Partial sum along axis 0:

json
{ "dataset": "a", "sum": 0 }
toml
dataset = "a"
sum = 0

Named axis mean:

json
{ "dataset": "temperature", "mean": "time" }
toml
dataset = "temperature"
mean = "time"

NaN-aware stats

KeyScalar fieldNotes
nan_meanoperation_nan_meanMean over finite elements only
nan_stdoperation_nan_stdStd over finite elements only
json
{ "dataset": "temperature", "nan_mean": [] }
toml
dataset = "temperature"
nan_mean = []

QC / finiteness

KeyScalar fieldPartial fields
nan_countoperation_nan_countoperation_reduced_nan_count, …
inf_countoperation_inf_countintegers contribute 0
any_infoperation_any_infboolean; integers contribute false
any_nanoperation_any_nanboolean
all_finiteoperation_all_finiteboolean
null_countoperation_null_countfill from query fill or dataset attrs

Null count with custom fill:

json
{
  "dataset": "temperature",
  "null_count": { "fill": 99, "axis": 0 }
}
toml
dataset = "temperature"

[null_count]
fill = 99
axis = 0

Index ops

KeyScalar fieldPartial fields
arg_minoperation_argmin_indexoperation_reduced_argmin, …
arg_maxoperation_argmax_indexoperation_reduced_argmax, …

Scalar returns a logical row-major index into the selection; partial returns index within each reduced fiber.

Tier-C — materialize-required

Need full logical tensor order (in RAM or temp spill when over budget).

KeyResponse fieldsNotes
medianoperation_median / operation_reduced_medianScalar + partial axes
quantileoperation_quantile (q field) / operation_reduced_quantileLinear blend between adjacent ranks
histogramoperation_histogram_counts, operation_histogram_edgesPartial returns counts only (flat out_len × bins)
covarianceoperation_covariance, operation_covariance_orderRank-2 only; axis = observation dimension
correlationoperation_correlation, operation_correlation_orderRank-2 only

Quantile:

json
{ "dataset": "a", "quantile": { "q": 0.95 } }
toml
dataset = "a"

[quantile]
q = 0.95
json
{ "dataset": "a", "quantile": { "q": 0.5, "axis": 0 } }
toml
dataset = "a"

[quantile]
q = 0.5
axis = 0

Histogram:

json
{ "dataset": "a", "histogram": { "axis": 0, "bins": 10 } }
toml
dataset = "a"

[histogram]
axis = 0
bins = 10

Fixed bin edges (scalar; both min and max required when either is set):

json
{ "dataset": "a", "histogram": { "bins": 10, "min": 0, "max": 1 } }
toml
dataset = "a"

[histogram]
bins = 10
min = 0
max = 1

Covariance / correlation (2-D datasets; axis selects the observation dimension):

json
{ "dataset": "variables", "covariance": { "axis": 0 } }
toml
dataset = "variables"

[covariance]
axis = 0
json
{ "dataset": "variables", "correlation": 0 }
toml
dataset = "variables"
correlation = 0

Result is row-major order × order where order is the variable count (the non-observation axis length).

Transforms

Shape-preserving element-wise rewrite. f32 / f64 only.

MethodDescription
zscore(x − mean) / std
minmaxScale to [0, 1] using min/max
l1L1 normalize
l2L2 normalize
centerSubtract mean
scaleDivide by std
log1plog(1 + x)
sqrt√x
softmaxSoftmax along axis

Pass-1 fold stats appear in operation_* / operation_reduced_*. Zero denominator → NaN with capped transform_div_by_zero_indices warnings.

json
{
  "dataset": "temperature",
  "transform": { "method": "zscore", "axis": 0 },
  "write": { "target": "sidecar", "timestamp": false }
}
toml
dataset = "temperature"

[transform]
method = "zscore"
axis = 0

[write]
target = "sidecar"
timestamp = false

Spill export (not an operation key)

Use top-level "spill" with no reduction key to write the full logical selection as dtype-native little-endian bytes:

json
{ "dataset": "temperature", "spill": "export.bin" }
toml
dataset = "temperature"
spill = "export.bin"

Response includes execution.spill_*_path and byte counts. Preview (when enabled) is read from the spilled file.

Preview-only (no operation, no spill)

When -x is set but the document has no operation or spill, the engine materializes a capped preview of the selection into dtype-matched arrays (f32_preview, u8_preview, …). Cap controlled by --preview.

json
{
  "dataset": "temperature",
  "selection": { "start": [0, 0], "stop": [2, 3] }
}
toml
dataset = "temperature"

[selection]
start = [0, 0]
stop = [2, 3]
bash
tet query preview.toml -t data.tet -x --format table --preview 6

Response field cheat sheet

After execution (-x), check execution in the response:

FieldWhen present
memory_strategystreaming_fold, capped_in_memory, in_memory_materialize, temp_spill_materialize, mmap_spill, transform_*
io_regimein_core / out_of_core (streaming fold)
fold_parallel / fold_linear_scanFold I/O path details
device_requested / device_used / device_fallback_reasonGPU routing (experimental)
memory_budget_bytes / logical_selection_bytesBudget resolution
operation_*Scalar aggregates (never truncated by preview cap)
operation_reduced_* / operation_reduced_shapePartial-axis results
transform_methodTransform pass-1 method name

Use --format stats for aggregates without chunk lists or preview arrays; --format quiet for scripting.

Fixture queries

The tetration repo ships paired .json / .toml fixtures in fixtures/queries/ — useful golden tests and starting points.

Latka Industries