Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 18 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, }, Parameter { name: StrRef, }, List { items: Slice, }, Row { items: Slice, }, Subquery { query: QueryRef, }, 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

§qualifier: Slice

The qualifier, as a run of StrRef, empty for a bare star.

§replacements: Slice

REPLACE (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.

Fields

§name: Slice

The name, as a run of StrRef, outermost first, so s.t.a is three parts.

§

Literal

A literal, kept as the text that was written.

Fields

§kind: LiteralKind

Which kind.

§text: StrRef

The text, with quotes stripped and escapes resolved for a string, NONE for a keyword literal like NULL where the kind already says everything.

§

Unary

A prefix or postfix operator.

Fields

§op: UnaryOp

Which operator.

§operand: ExprRef

What it applies to.

§

Binary

An infix operator.

Fields

§op: BinaryOp

Which operator.

§left: ExprRef

The left operand.

§right: ExprRef

The right operand.

§

Function

A function call.

Fields

§name: Slice

The name, as a run of StrRef, so main.count is two parts.

§args: Slice

The arguments, as a run of ExprRef.

§distinct: bool

Whether the call said DISTINCT.

§filter: ExprRef

The FILTER (WHERE ...) predicate, or NONE. Kept on every call and not only on the ones that can carry it, because which names can carry it is a question about the function catalog and the parser does not have one.

§

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

§name: Slice

The name, as a run of StrRef, so main.sum is two parts.

§args: Slice

The arguments, as a run of ExprRef.

§distinct: bool

Whether the call said DISTINCT.

§filter: ExprRef

The 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: bool

Whether 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.

§order: Slice

The ORDER BY written inside the brackets, as a run of OrderItem, empty when there was none. This is the order the call reads the rows of its frame in, and it has nothing to do with the ORDER BY in the OVER, which lays the partition out.

§spec: WindowRef

The window itself, into Ast::windows.

§

Cast

CAST(x AS t) or TRY_CAST(x AS t).

Fields

§operand: ExprRef

What is being cast.

§ty: StrRef

The target type, as the text it was written with. Parsing it is rudb-common’s job and doing it here would put the type system in the parser.

§try_cast: bool

Whether a failure yields null rather than an error.

§

Case

CASE, searched or simple.

Fields

§operand: ExprRef

The operand of a simple CASE x WHEN, or NONE for a searched one.

§arms: Slice

The arms, as a run of CaseArm.

§otherwise: ExprRef

The ELSE, or NONE.

§

Between

x BETWEEN a AND b.

Fields

§operand: ExprRef

What is being tested.

§low: ExprRef

The lower bound.

§high: ExprRef

The upper bound.

§negated: bool

Whether it was written NOT BETWEEN.

§

In

x IN (a, b, c).

Fields

§operand: ExprRef

What is being tested.

§list: Slice

The list, as a run of ExprRef.

§negated: bool

Whether it was written NOT IN.

§

InSubquery

x IN (SELECT ...) or its negation.

Fields

§operand: ExprRef

What is being tested.

§query: QueryRef

The query producing the candidates.

§negated: bool

Whether it was written NOT IN.

§

QuantifiedSubquery

x op ANY (SELECT ...) or x op ALL (SELECT ...).

Fields

§operand: ExprRef

The value on the left of the comparison.

§op: BinaryOp

The comparison applied to each candidate.

§query: QueryRef

The query producing the candidates.

§all: bool

Whether the quantifier was ALL rather than ANY.

§

Parameter

A prepared statement parameter, written ?, ?1, $1 or $name.

Fields

§name: StrRef

The identifier, which is the number for a positional one and the word for a named one. A bare ? is numbered by where it was written, so the identifier is there either way.

§

List

A bracketed list of expressions, [a, b, c], which is a LIST value.

Fields

§items: Slice

The items, as a run of ExprRef, in the order they were written.

§

Row

A parenthesised list of more than one expression, which is a row value.

Fields

§items: Slice

The items, as a run of ExprRef.

§

Subquery

A scalar subquery, (SELECT ...) where an expression is expected.

Fields

§query: QueryRef

The query.

§

Exists

EXISTS (SELECT ...) or its negation.

Fields

§query: QueryRef

The query whose cardinality is tested.

§negated: bool

Whether NOT was written before EXISTS.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Expr

Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Expr

Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.