Skip to main content

Module expression

Module expression 

Source
Expand description

Scalar expression evaluator (ROADMAP v0.5.0 item A).

A row → Value evaluator for the SELECT-projection scalar functions the Phase 1–9 SQL coverage uplift intentionally deferred. Keeps the kernel pure (no IO, no clocks, no randomness) — anything that needs the wallclock threads a clock parameter in at the call site so VOPR’s determinism contract is preserved.

Currently supports:

  • Literals — every Value variant (Text, Numeric, Boolean, …)
  • Column references — resolved against the projection’s column map
  • String functions: UPPER, LOWER, LENGTH (char count), TRIM, CONCAT, ||
  • Numeric functions: ABS, ROUND(x), ROUND(x, scale), CEIL, CEILING, FLOOR
  • Null/type coercion: COALESCE(a, b, …), NULLIF(a, b)

Added in v0.5.1:

  • CAST(x AS T) — numeric subtype conversions, numeric ↔ Text parsing/formatting, Boolean ↔ Text, and NULL preservation. The predicate-level integration landed with the ScalarCmp Predicate variant in the parser.

Still deferred:

  • MOD, POWER, SQRT (number-theoretic — need proper overflow handling across TinyInt/SmallInt/Integer/BigInt/Real)
  • SUBSTRING, EXTRACT, DATE_TRUNC, NOW(), CURRENT_TIMESTAMP, CURRENT_DATE, interval arithmetic — need a clock-threading decision we haven’t made yet (VOPR sim clock vs production wall clock)

Each function is a whitelisted, named variant on ScalarExpr — deliberately not a dynamic-dispatch table, so a typo in a SQL function name is rejected at planning time rather than runtime.

Structs§

EvalContext
A row paired with its column map, passed to evaluate. The column map is an ordered list of names matching the row’s positional layout.

Enums§

ScalarExpr
A scalar expression that evaluates to a Value against a row.

Functions§

evaluate
Evaluate a scalar expression against a row.