pub enum Expr {
Show 21 variants
Star {
qualifier: Slice,
replacements: Slice,
},
Column {
name: Slice,
},
Literal {
kind: LiteralKind,
text: StrRef,
},
Unary {
op: UnaryOp,
operand: ExprRef,
},
Binary {
op: BinaryOp,
left: ExprRef,
right: ExprRef,
},
Function {
name: Slice,
args: Slice,
distinct: bool,
filter: ExprRef,
},
Window {
name: Slice,
args: Slice,
distinct: bool,
filter: ExprRef,
ignore_nulls: bool,
order: Slice,
spec: WindowRef,
},
Cast {
operand: ExprRef,
ty: StrRef,
try_cast: bool,
},
Case {
operand: ExprRef,
arms: Slice,
otherwise: ExprRef,
},
Between {
operand: ExprRef,
low: ExprRef,
high: ExprRef,
negated: bool,
},
In {
operand: ExprRef,
list: Slice,
negated: bool,
},
InSubquery {
operand: ExprRef,
query: QueryRef,
negated: bool,
},
QuantifiedSubquery {
operand: ExprRef,
op: BinaryOp,
query: QueryRef,
all: bool,
},
Default,
Parameter {
name: StrRef,
},
List {
items: Slice,
},
Lambda {
params: Slice,
body: ExprRef,
},
Struct {
names: Slice,
values: Slice,
},
Row {
items: Slice,
},
Subquery {
query: QueryRef,
array: bool,
},
Exists {
query: QueryRef,
negated: bool,
},
}Expand description
One expression.
Twenty four bytes, which is the widest variant rounded up. The precedence chain in the grammar
does not survive into here: twenty levels of X <- Y Tail* become one Expr::Binary tree,
because the levels exist to make the grammar unambiguous and mean nothing afterwards.
Variants§
Star
*, or t.* with a qualifier.
Fields
replacements: SliceREPLACE (expression AS column), as a run of Target where the alias is the column
being replaced, empty for a star with no replace list.
A Target rather than a type of its own because a replacement is an expression and a
name, which is exactly what a target is, and because that puts it in the arena every
other expression and name pair already lives in.
Column
A column reference, qualified or not.
Literal
A literal, kept as the text that was written.
Fields
kind: LiteralKindWhich kind.
Unary
A prefix or postfix operator.
Binary
An infix operator.
Fields
Function
A function call.
Fields
Window
A function call with an OVER on the end of it.
Kept apart from Expr::Function rather than given an optional window, because the two
are different things by every rule that applies to them: a window call is refused in a
WHERE and in a HAVING, it may not appear inside an aggregate, and it resolves against a
different set of names. A variant that only some of the code has to remember to look at is
a variant the rest of the code gets wrong.
Fields
filter: ExprRefThe FILTER (WHERE ...) predicate, or NONE. It is written before the OVER and not
after it, which is a rule of the grammar rather than of the binder.
ignore_nulls: boolWhether the call said IGNORE NULLS. RESPECT NULLS is the default and is not kept,
because the reference binary drops it: a view written with it comes back without it.
Cast
CAST(x AS t) or TRY_CAST(x AS t).
Fields
Case
CASE, searched or simple.
Fields
Between
x BETWEEN a AND b.
Fields
In
x IN (a, b, c).
Fields
InSubquery
x IN (SELECT ...) or its negation.
Fields
QuantifiedSubquery
x op ANY (SELECT ...) or x op ALL (SELECT ...).
Fields
Default
DEFAULT where a value is written, which is the column’s default and only means something
as a whole item of an INSERT’s VALUES row.
Parameter
A prepared statement parameter, written ?, ?1, $1 or $name.
Fields
List
A bracketed list of expressions, [a, b, c], which is a LIST value.
Lambda
LAMBDA x, i: body, a function written inline as the argument of one that takes it.
It is an expression only so that it can sit in an argument list. Anywhere else it means nothing, and the binder says so in upstream’s words rather than the parser refusing it, because upstream’s parser accepts it anywhere too.
Fields
Struct
A braced struct, {'a': 1, b: 2}, which is a STRUCT value with the field names written.
Fields
Row
A parenthesised list of more than one expression, which is a row value.
Subquery
A scalar subquery, (SELECT ...) where an expression is expected.
Fields
Exists
EXISTS (SELECT ...) or its negation.