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>,
    },
    Window {
        name: StrRef,
        args: Slice,
        distinct: bool,
        filter: Option<ExprRef>,
        ignore_nulls: bool,
        order: Slice,
    },
    Case {
        arms: Slice,
        otherwise: Option<ExprRef>,
    },
    Lambda {
        table: u32,
        params: Slice,
        body: ExprRef,
    },
    LambdaParam(ColumnBinding),
}
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.

§

Window

A window function, evaluated by the Node::Window that lists it.

Fields

§name: StrRef

The resolved scalar, aggregate, or dedicated window function name.

§args: Slice

Function arguments over the window input.

§distinct: bool

Whether duplicate argument tuples are collapsed first.

§filter: Option<ExprRef>

An aggregate filter, when the window call has one.

§ignore_nulls: bool

Whether null arguments are skipped by functions that support the modifier.

§order: Slice

The order the call reads the rows of its frame in, into the sort key pool, empty when the call wrote no ORDER BY inside its brackets.

This is not the window’s own ordering. The one in the OVER lays the partition out and decides which rows are in the frame at all, and this one decides what order the call sees them in once they are, which is why first_value(v ORDER BY v DESC) is the largest v in the frame and not the first row of it.

§

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.

§

Lambda

A function written inline, which is only ever an argument of a function that takes one, such as the second argument of list_transform.

Its parameters are bound as the columns of a table of their own, numbered the way an operator’s output is, and read with Expr::LambdaParam. The type recorded for it is its body’s, since there is no type for a function and the one its caller needs is the body’s.

Fields

§table: u32

The table index its parameters are bound under.

§params: Slice

The parameters as they were written, into the name list pool, which is what an error message quotes a body with.

§body: ExprRef

What it computes from them.

§

LambdaParam(ColumnBinding)

One parameter of an enclosing Expr::Lambda.

Not an Expr::Column, although the body reads it the same way when it runs, because no operator produces it. A pass that moves, prunes or renumbers columns has to be able to tell one apart from a column without knowing which lambda it is inside, and a variant of its own is what lets it.

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