Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
    Column(ColumnBinding),
    Constant(ValueRef),
    Cast {
        input: ExprRef,
        try_cast: bool,
    },
    Compare {
        op: CompareOp,
        left: ExprRef,
        right: ExprRef,
    },
    Conjunction {
        op: ConjunctionOp,
        children: Slice,
    },
    Function {
        name: StrRef,
        args: Slice,
    },
    Aggregate {
        name: StrRef,
        args: Slice,
        distinct: bool,
        filter: Option<ExprRef>,
    },
    Case {
        arms: Slice,
        otherwise: Option<ExprRef>,
    },
}
Expand description

One bound expression.

The type of an expression is not in here. It lives in a parallel vector in Plan, indexed by the same ExprRef, because a LogicalType owns a Vec for its nested cases and putting one inside every variant would make the common variants three times larger for the benefit of the rare ones.

Variants§

§

Column(ColumnBinding)

A reference to a column of some operator’s output.

§

Constant(ValueRef)

A literal, folded constant, or bound parameter value.

§

Cast

A cast to the expression’s own type.

The target is the type stored for this expression, not a second copy of it, so there is no way for a cast to disagree with its own result type.

Fields

§input: ExprRef

What is being cast.

§try_cast: bool

Whether a failed cast yields null instead of raising.

§

Compare

A binary comparison.

Fields

§op: CompareOp

Which comparison.

§left: ExprRef

Left operand.

§right: ExprRef

Right operand.

§

Conjunction

An AND or OR over two or more operands.

Flat rather than binary, because filter pushdown splits a conjunction into its parts and a right-leaning tree of two-argument ANDs makes that a recursion instead of a loop.

Fields

§op: ConjunctionOp

Which connective.

§children: Slice

Two or more operands, into the expression list pool.

§

Function

A scalar function, already resolved to one overload by the binder.

The name is the resolved function’s name and not the name the user wrote, so a + b is a call to + and an alias in the catalog has already been followed.

Fields

§name: StrRef

The resolved function name.

§args: Slice

The arguments, into the expression list pool.

§

Aggregate

An aggregate function.

An aggregate appears only as a direct element of Node::Aggregate’s aggregate list. Anything downstream that wants the result refers to it with a ColumnBinding into the aggregate’s table index, which is why that node has one. Plan::validate checks this, and the textual form relies on it: an aggregate and a scalar function print the same way, and it is the slot they are printed in that says which is which.

Fields

§name: StrRef

The resolved aggregate name.

§args: Slice

The arguments, into the expression list pool.

§distinct: bool

Whether duplicate input rows are collapsed before aggregating.

§filter: Option<ExprRef>

The FILTER (WHERE ...) predicate, if there is one.

§

Case

A searched CASE.

There is no simple CASE here. CASE x WHEN 1 THEN ... is rewritten to the searched form by the binder, because two representations of one thing is two code paths in every pass that touches either.

Fields

§arms: Slice

The WHEN/THEN pairs, in order, into the arm pool.

§otherwise: Option<ExprRef>

The ELSE, if there is one. Absent means null.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 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: &Expr) -> 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.