Expand description
Expression evaluator. Given a parsed Expr, a Row, and the row’s column
schema, produce a Value. v0.4 implements:
- literals
- column lookups (bare and qualified
t.col) - unary minus / NOT
- binary arithmetic, comparison, AND, OR
- numeric widening (
Int → BigInt → Float) at evaluation time - SQL three-valued logic for NULL:
- any arithmetic / comparison op with a NULL operand → NULL
TRUE OR NULL→ TRUE,FALSE OR NULL→ NULL,FALSE AND NULL→ FALSE,TRUE AND NULL→ NULL,NOT NULL→ NULL
v0.4 deliberately does not implement: function calls, string concatenation, IS NULL / IS NOT NULL, BETWEEN, IN, etc. Those come later.
Structs§
- Eval
Context - Resolution context for evaluating a single row.
table_aliasis the alias (or table name) callers should accept as the qualifier on a column ref — e.g.FROM users AS umakesu.namevalid and rejectsother.name.
Enums§
Functions§
- cast_
to_ vector - Parse a
Value::Text("[1.0, 2.0, 3.0]")into aValue::Vector(..). Mirrors pgvector’s'[..]'::vectorcast. NULL casts as NULL. - cast_
value - PG-style
expr::TYPEcoercion. NULL always casts as NULL. - days_
from_ civil - Inverse of
civil_from_days— converts (year, month, day) to days since 1970-01-01. Out-of-range months / days saturate. - eval_
expr - format_
bytea_ hex - v7.10.4 — render a BYTEA payload in PG’s hex output format
(
\xprefix, lowercase hex pairs). Public so the wire layer can emit the canonical bytea-as-text representation. - format_
date - Render a
Date(days since epoch) asYYYY-MM-DD. Negative values for pre-1970 dates render with a leading-on the year. - format_
interval - Render an
Interval { months, micros }in a PG-ish shape. The output mirrorspsql’s text format: years/months from the months part, days/HH:MM:SS[.frac] from the microsecond part. Empty parts are omitted; an all-zero interval renders as0. - format_
numeric - Render a
Numeric { scaled, scale }as its decimal text form. Negativescaledprepends-to the absolute value’s digits; the integer / fractional split is by character count, padding the fractional side with leading zeros to exactlyscalechars. - format_
timestamp - Render a
Timestamp(microseconds since epoch) asYYYY-MM-DD HH:MM:SS[.fff...]. Trailing-zero fractional digits are dropped; a whole-second value has no fractional part. - parse_
date_ literal - Parse
YYYY-MM-DDinto aDate(days since Unix epoch). ReturnsNoneon shape / numeric failure; the engine surfaces that as aTypeMismatchwith the original text included. - parse_
timestamp_ literal - Parse
YYYY-MM-DD[ HH:MM:SS[.ffffff]]into aTimestamp(microseconds since Unix epoch). The time portion is optional; missing → midnight. The fractional portion accepts 1–6 digits and pads with zeros to microseconds.