Skip to main content

Module scalar

Module scalar 

Source
Expand description

A pure scalar evaluator: one formula, one value per input, no dimensions.

This is the engine’s per-cell semantics without the dataflow around it. It calls the very operators the dataflow builder maps over its collections (apply_binary, apply_unary, apply_scalar), so a formula evaluated here gives the bit-identical value the engine gives at a single coordinate. pg_improv’s LANGUAGE improv evaluates SQL function bodies with it.

Semantics:

  • a Ref to a measure absent from env is a missing input: the result is None wherever it depends on it (the dataflow emits no cell there);
  • division by zero and domain errors are NaN (the engine’s convention);
  • aggregations and dimension projections (SUM(x OVER T), x BY T) need a model with categories and are rejected with ScalarError::NeedsDimensions.

Enums§

ScalarError
Why a formula cannot be evaluated as a scalar.

Functions§

check
Reject what a scalar evaluation cannot do, before evaluating anything, so the error does not depend on which inputs happen to be NULL.
eval
Evaluate expr with each referenced measure’s value taken from env.