pub enum Expr {
Show 17 variants
Literal(Literal),
Column(ColumnName),
Placeholder(u16),
Binary {
lhs: Box<Expr>,
op: BinOp,
rhs: Box<Expr>,
},
Unary {
op: UnOp,
expr: Box<Expr>,
},
Cast {
expr: Box<Expr>,
target: CastTarget,
},
IsNull {
expr: Box<Expr>,
negated: bool,
},
FunctionCall {
name: String,
args: Vec<Expr>,
},
Like {
expr: Box<Expr>,
pattern: Box<Expr>,
negated: bool,
},
WindowFunction {
name: String,
args: Vec<Expr>,
partition_by: Vec<Expr>,
order_by: Vec<(Expr, bool)>,
frame: Option<WindowFrame>,
null_treatment: NullTreatment,
},
ScalarSubquery(Box<SelectStatement>),
Exists {
subquery: Box<SelectStatement>,
negated: bool,
},
InSubquery {
expr: Box<Expr>,
subquery: Box<SelectStatement>,
negated: bool,
},
Extract {
field: ExtractField,
source: Box<Expr>,
},
Array(Vec<Expr>),
ArraySubscript {
target: Box<Expr>,
index: Box<Expr>,
},
AnyAll {
expr: Box<Expr>,
op: BinOp,
array: Box<Expr>,
is_any: bool,
},
}Variants§
Literal(Literal)
Column(ColumnName)
Placeholder(u16)
v6.1.1 — $N parameter placeholder for the extended query
protocol. The number is 1-based per PostgreSQL convention.
Evaluation looks up params[N-1] from the prepared-statement
bind buffer; out-of-range indices raise a runtime error
(same shape as a column-not-found miss).
Binary
Unary
Cast
PG-style expr::TYPE cast. v1.3 supports VECTOR, INT, BIGINT, FLOAT,
TEXT, BOOL targets; engine coerces at evaluation time.
IsNull
Postfix IS NULL / IS NOT NULL. Returns BOOL.
FunctionCall
Function call name(args...). v1.4 supports a small built-in set
(length, upper, lower, abs, coalesce); unknown names error at eval
time so the parser stays open for v1.5 aggregates.
Like
SQL LIKE predicate. pattern evaluates to text at runtime;
wildcards are % (any run) and _ (one char), backslash escapes
the next char (so \% matches a literal %).
WindowFunction
v4.12 window function call: name(args) OVER (PARTITION BY ... ORDER BY ...). Supports ROW_NUMBER / RANK /
DENSE_RANK and the partition-aware aggregates SUM /
AVG / COUNT / MIN / MAX. The window frame defaults to “entire partition” for
unordered windows and “from start of partition through
current row” for ordered windows — no explicit ROWS /
RANGE clause in v4.12 MVP.
Fields
frame: Option<WindowFrame>v4.20 explicit frame. None means “use the default”:
whole-partition when unordered, running aggregate from
partition start through current row when ordered.
null_treatment: NullTreatmentv6.4.2 — IGNORE NULLS / RESPECT NULLS modifier on
LAG / LEAD / FIRST_VALUE / LAST_VALUE. Default is
Respect (PG / ANSI default — NULLs participate). Other
window functions ignore this flag.
ScalarSubquery(Box<SelectStatement>)
v4.10 scalar subquery — (SELECT ...) used in expression
position. Must return exactly one row × one column at eval
time; the engine errors out otherwise. Uncorrelated only —
the inner SELECT cannot reference outer columns.
Exists
v4.10 [NOT] EXISTS (SELECT ...). Returns Bool. Inner
projection is ignored; only row-count matters.
InSubquery
v4.10 expr [NOT] IN (SELECT ...). Inner SELECT must
project exactly one column; membership is tested by Eq
against each row’s value (NULL handling follows ANSI:
NULL ∈ list ⇒ NULL ; otherwise present ⇒ true).
Extract
EXTRACT(<field> FROM <source>) — pull an integer component
out of a DATE or TIMESTAMP. Parsed as its own AST node
because the FROM keyword is what separates the two halves,
not a comma.
Array(Vec<Expr>)
v7.10.10 — ARRAY[expr, expr, …] array constructor. Each
element is evaluated independently; NULLs are allowed.
v7.10 supports only single-dimension TEXT[] semantically;
non-text elements coerce at engine evaluation time when
the surrounding context (column type / cast) makes the
target clear.
ArraySubscript
v7.10.10 — array subscript arr[i]. PG 1-based; the
engine returns NULL for out-of-range indices.
AnyAll
v7.10.12 — expr op ANY(arr) and expr op ALL(arr). The
operator is the comparison binary op (Eq / Ne / Lt / …);
the engine desugars: ANY returns true if any element
satisfies; ALL returns true only if every element does.
NULL handling follows PG’s three-valued logic.