pub enum ScalarExpr {
Show 15 variants
Literal(Value),
Column(ColumnName),
Upper(Box<ScalarExpr>),
Lower(Box<ScalarExpr>),
Length(Box<ScalarExpr>),
Trim(Box<ScalarExpr>),
Concat(Vec<ScalarExpr>),
Abs(Box<ScalarExpr>),
Round(Box<ScalarExpr>),
RoundScale(Box<ScalarExpr>, i32),
Ceil(Box<ScalarExpr>),
Floor(Box<ScalarExpr>),
Coalesce(Vec<ScalarExpr>),
Nullif(Box<ScalarExpr>, Box<ScalarExpr>),
Cast(Box<ScalarExpr>, DataType),
}Expand description
A scalar expression that evaluates to a Value against a row.
Pressurecraft: pure over its inputs (no IO, no clocks, no RNG). Every variant’s evaluation is deterministic — same inputs produce the same output. VOPR-safe.
Variants§
Literal(Value)
Literal value.
Column(ColumnName)
Reference to a row column by name.
Upper(Box<ScalarExpr>)
UPPER(s) — ASCII-preserving uppercase via Unicode simple mapping.
Lower(Box<ScalarExpr>)
LOWER(s) — Unicode simple lowercase.
Length(Box<ScalarExpr>)
LENGTH(s) — character count (not byte count).
Trim(Box<ScalarExpr>)
TRIM(s) — strip ASCII whitespace from both ends.
Concat(Vec<ScalarExpr>)
CONCAT(a, b, …) — string concatenation. A NULL operand makes
the whole result NULL (PostgreSQL-compatible, differs from MySQL).
Abs(Box<ScalarExpr>)
ABS(n) — absolute value. Preserves the integer subtype when the
argument is an integer; returns Real for Real; returns
Decimal (same scale) for Decimal.
Round(Box<ScalarExpr>)
ROUND(x) — half-away-from-zero. For integers this is identity.
RoundScale(Box<ScalarExpr>, i32)
ROUND(x, scale) — round to scale decimal places. Only
meaningful for Real / Decimal operands; integer operands are
returned unchanged.
Ceil(Box<ScalarExpr>)
CEIL(x) / CEILING(x) — least integer >= x.
Floor(Box<ScalarExpr>)
FLOOR(x) — greatest integer <= x.
Coalesce(Vec<ScalarExpr>)
COALESCE(e1, e2, …) — first non-NULL argument, or NULL.
Nullif(Box<ScalarExpr>, Box<ScalarExpr>)
NULLIF(a, b) — NULL if a == b, otherwise a.
Cast(Box<ScalarExpr>, DataType)
CAST(x AS T) — convert x to the target DataType.
NULL in → NULL out for every target. Overflow on narrowing
integer casts and unparseable strings surface as
QueryError::TypeMismatch rather than silent truncation.
Trait Implementations§
Source§impl Clone for ScalarExpr
impl Clone for ScalarExpr
Source§fn clone(&self) -> ScalarExpr
fn clone(&self) -> ScalarExpr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more