Skip to main content

LogicalPlan

Enum LogicalPlan 

Source
pub enum LogicalPlan {
Show 17 variants Scan { table: String, alias: Option<String>, limit: Option<usize>, }, Filter { input: Box<LogicalPlan>, predicate: String, }, Project { input: Box<LogicalPlan>, columns: Vec<String>, }, Join { left: Box<LogicalPlan>, right: Box<LogicalPlan>, on: String, join_type: JoinType, algo_hint: Option<JoinAlgoHint>, }, Aggregate { input: Box<LogicalPlan>, group_by: Vec<String>, aggregates: Vec<String>, }, Sort { input: Box<LogicalPlan>, order_by: Vec<SortExpr>, }, Limit { input: Box<LogicalPlan>, count: Option<u64>, offset: Option<u64>, }, Values { columns: Vec<String>, rows: usize, }, Empty, SetOp { op: SetOpType, all: bool, left: Box<LogicalPlan>, right: Box<LogicalPlan>, }, Cte { name: String, query: Box<LogicalPlan>, recursive: bool, }, CteRef { name: String, }, Window { input: Box<LogicalPlan>, functions: Vec<WindowFunctionDef>, }, Subquery { query: Box<LogicalPlan>, alias: Option<String>, }, Exists { subquery: Box<LogicalPlan>, negated: bool, }, InSubquery { expr: String, subquery: Box<LogicalPlan>, negated: bool, }, Compute { input: Box<LogicalPlan>, bindings: Vec<(String, String)>, },
}
Expand description

AST-level logical query plan produced by crate::plan_statement.

Each variant represents a relational algebra operator. The tree is built bottom-up: leaf nodes (e.g. Scan) are wrapped by operator nodes (Filter, Project, …) as query features are encountered.

Variants§

§

Scan

Table scan. alias is the AS alias, if any.

Fields

§table: String

The fully-qualified table name as it appears in the query.

§alias: Option<String>

Optional alias (AS x).

§limit: Option<usize>

Optional row-count cap injected by the optimizer’s limit push-through pass. None means the scan is unbounded.

§

Filter

Row filter (WHERE).

Fields

§input: Box<LogicalPlan>

The plan being filtered.

§predicate: String

The WHERE expression rendered as a string.

§

Project

Column projection (SELECT col1, col2, …).

Fields

§input: Box<LogicalPlan>

The plan whose rows are projected.

§columns: Vec<String>

The projected column expressions as strings.

§

Join

Binary join of two inputs.

Fields

§left: Box<LogicalPlan>

Left input.

§right: Box<LogicalPlan>

Right input.

§on: String

The ON expression rendered as a string.

§join_type: JoinType

The join type (INNER, LEFT, RIGHT, FULL, CROSS).

§algo_hint: Option<JoinAlgoHint>

Algorithm hint set by crate::optimizer::JoinAlgorithmPass.

§

Aggregate

Aggregation (GROUP BY / aggregate functions).

Fields

§input: Box<LogicalPlan>

The plan whose rows are aggregated.

§group_by: Vec<String>

GROUP BY expressions rendered as strings.

§aggregates: Vec<String>

Aggregate function expressions rendered as strings.

§

Sort

Row ordering (ORDER BY).

Fields

§input: Box<LogicalPlan>

The plan whose rows are sorted.

§order_by: Vec<SortExpr>

The sort key expressions.

§

Limit

Row count / offset restriction (LIMIT … OFFSET …).

Fields

§input: Box<LogicalPlan>

The plan being limited.

§count: Option<u64>

Maximum number of rows, if specified.

§offset: Option<u64>

Number of rows to skip, if specified.

§

Values

Constant row source (INSERT … VALUES …).

Fields

§columns: Vec<String>

Column names from the INSERT column list.

§rows: usize

Number of value rows.

§

Empty

Placeholder for statements that produce no relational plan.

§

SetOp

A SQL set operation: UNION, INTERSECT, or EXCEPT.

Fields

§op: SetOpType

The set-operation kind.

§all: bool

true for UNION ALL / INTERSECT ALL / EXCEPT ALL.

§left: Box<LogicalPlan>

Left input plan.

§right: Box<LogicalPlan>

Right input plan.

§

Cte

A CTE definition node.

The query field is the plan for the CTE’s own defining body (AS (...)). The query that uses this CTE is built by the surrounding planner; this variant retains only the CTE definition itself.

Fields

§name: String

The CTE name as introduced before the AS keyword.

§query: Box<LogicalPlan>

Plan for the CTE-defining sub-query (AS ( ... )).

§recursive: bool

true when the entire WITH clause was WITH RECURSIVE.

§

CteRef

Reference to a previously defined CTE by name.

Fields

§name: String

The CTE name being referenced.

§

Window

Window-function layer sitting over a base plan.

Fields

§input: Box<LogicalPlan>

The input plan over which windows are computed.

§functions: Vec<WindowFunctionDef>

The window functions defined in the SELECT projection.

§

Subquery

A scalar subquery that returns a single value (used in SELECT or WHERE).

Fields

§query: Box<LogicalPlan>

The inner query plan.

§alias: Option<String>

Optional alias applied to the subquery expression.

§

Exists

EXISTS (subquery) — used in WHERE predicates.

Fields

§subquery: Box<LogicalPlan>

The inner subquery plan.

§negated: bool

true when the expression is NOT EXISTS.

§

InSubquery

expr IN (subquery) — used in WHERE predicates.

Fields

§expr: String

The expression being tested (e.g. "col1").

§subquery: Box<LogicalPlan>

The inner subquery plan.

§negated: bool

true when the expression is NOT IN.

§

Compute

A plan node that materializes named expression bindings for CSE.

Each (alias, expr_string) pair in bindings declares a named intermediate value that downstream nodes can reference by alias. A Compute node is an optimization artifact introduced by the common-subexpression-elimination pass; it adds zero compute overhead and is transparent to most plan traversals.

Fields

§input: Box<LogicalPlan>

The input plan whose output rows are annotated with bindings.

§bindings: Vec<(String, String)>

Named expression bindings: (alias, expr_string) pairs.

Trait Implementations§

Source§

impl Clone for LogicalPlan

Source§

fn clone(&self) -> LogicalPlan

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 LogicalPlan

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.