Skip to main content

LogicalPlan

Enum LogicalPlan 

Source
pub enum LogicalPlan {
Show 24 variants Pragma { name: String, value: Option<PragmaValue>, }, Scan { table: String, projection: Projection, }, Values { rows: Vec<Vec<TypedExpr>>, schema: Vec<ColumnMetadata>, }, Filter { input: Box<LogicalPlan>, predicate: TypedExpr, }, Project { input: Box<LogicalPlan>, projection: Projection, }, Join { left: Box<LogicalPlan>, right: Box<LogicalPlan>, join_type: JoinType, condition: Option<TypedExpr>, using: Option<Vec<String>>, }, LateralJoin { left: Box<LogicalPlan>, right: Box<LogicalPlan>, join_type: JoinType, condition: Option<TypedExpr>, right_schema: Vec<ColumnMetadata>, }, TableFunction { function: TableFunctionKind, args: Vec<TypedExpr>, schema: Vec<ColumnMetadata>, }, Aggregate { input: Box<LogicalPlan>, group_keys: Vec<TypedExpr>, aggregates: Vec<AggregateExpr>, having: Option<TypedExpr>, projection: Projection, grouping_sets: Option<Vec<u64>>, }, Window { input: Box<LogicalPlan>, windows: Vec<WindowExpr>, }, SetOperation { left: Box<LogicalPlan>, right: Box<LogicalPlan>, operator: SetOperator, all: bool, }, RecursiveCte { name: String, anchor: Box<LogicalPlan>, recursive_term: Box<LogicalPlan>, union_all: bool, schema: Vec<ColumnMetadata>, limits: RecursiveCteLimits, }, RecursiveReference { name: String, schema: Vec<ColumnMetadata>, }, Sort { input: Box<LogicalPlan>, order_by: Vec<SortExpr>, }, DistinctOn { input: Box<LogicalPlan>, key_count: usize, order_by: Vec<SortExpr>, }, Limit { input: Box<LogicalPlan>, limit: Option<u64>, offset: Option<u64>, ties: Option<Vec<SortExpr>>, }, Insert { table: String, columns: Vec<String>, values: Vec<Vec<TypedExpr>>, }, InsertSelect { table: String, columns: Vec<String>, source: Box<LogicalPlan>, }, Update { table: String, assignments: Vec<TypedAssignment>, filter: Option<TypedExpr>, }, Delete { table: String, filter: Option<TypedExpr>, }, CreateTable { table: TableMetadata, if_not_exists: bool, with_options: Vec<(String, String)>, }, DropTable { name: String, if_exists: bool, }, CreateIndex { index: IndexMetadata, if_not_exists: bool, }, DropIndex { name: String, if_exists: bool, },
}
Expand description

Logical query plan representation.

This enum represents all possible logical operations that can be performed. Plans are organized into three categories:

  1. Query Plans: Read operations (Scan, Filter, Sort, Limit)
  2. DML Plans: Data modification (Insert, Update, Delete)
  3. DDL Plans: Schema modification (CreateTable, DropTable, CreateIndex, DropIndex)

Variants§

§

Pragma

Runtime configuration or statistics operation.

Fields

§name: String

PRAGMA name.

§value: Option<PragmaValue>

Optional assignment value.

§

Scan

Table scan operation.

Scans all rows from a table with the specified projection. This is typically the leaf node of query plans.

Fields

§table: String

Table name to scan.

§projection: Projection

Columns to project (after wildcard expansion).

§

Values

Inline VALUES rows evaluated once per output row.

Fields

§rows: Vec<Vec<TypedExpr>>

Type-checked expressions for each row.

§schema: Vec<ColumnMetadata>

Common output schema inferred column-by-column across all rows.

§

Filter

Filter operation (WHERE clause).

Filters rows from the input plan based on a predicate.

Fields

§input: Box<LogicalPlan>

Input plan to filter.

§predicate: TypedExpr

Filter predicate (must evaluate to Boolean).

§

Project

Projection boundary.

Scan keeps the legacy single-table projection path; this node is used when a relation-producing input such as JOIN or a derived table must be materialized before being consumed by a parent query.

Fields

§input: Box<LogicalPlan>

Input plan to project.

§projection: Projection

Projection to apply.

§

Join

JOIN operation.

Fields

§left: Box<LogicalPlan>

Left input.

§right: Box<LogicalPlan>

Right input.

§join_type: JoinType

Join type.

§condition: Option<TypedExpr>

Optional ON condition.

§using: Option<Vec<String>>

Optional USING columns.

§

LateralJoin

LATERAL join (issue #151).

The right input is a correlated relation: it is planned against the left row and re-executed once per left row, so it cannot be reordered with or hoisted above the left side the way LogicalPlan::Join can.

Fields

§left: Box<LogicalPlan>

Left input, executed once.

§right: Box<LogicalPlan>

Correlated right input, executed once per left row with the left row supplied as the outer row.

§join_type: JoinType

Inner, Left, or Cross; RIGHT and FULL are rejected in planning.

§condition: Option<TypedExpr>

Optional ON condition over the concatenated (left, right) row.

§right_schema: Vec<ColumnMetadata>

Output schema of the right input, kept so a LEFT join can pad even when the left input is empty.

§

TableFunction

FROM-clause table function (issue #151).

Fields

§function: TableFunctionKind

Which function this node evaluates.

§args: Vec<TypedExpr>

Argument expressions, evaluated against the outer row.

§schema: Vec<ColumnMetadata>

Output schema.

§

Aggregate

Aggregate operation (GROUP BY / aggregation).

Aggregates rows from the input plan using group keys and aggregate expressions.

Fields

§input: Box<LogicalPlan>

Input plan to aggregate.

§group_keys: Vec<TypedExpr>

Group-by key expressions (empty for global aggregation).

§aggregates: Vec<AggregateExpr>

Aggregate expressions to compute.

§having: Option<TypedExpr>

HAVING filter applied after aggregation.

§projection: Projection

Projection to apply after aggregation.

§grouping_sets: Option<Vec<u64>>

Expanded GROUPING SETS masks over group_keys (issue #149).

None keeps the pre-grouping-sets single-set behavior. Each mask covers group_keys with key 0 at the most significant of the low group_keys.len() bits; a 1 bit marks the key as excluded from that grouping set (NULL placeholder in the output). When present, the aggregate output schema gains a trailing __grouping_id BIGINT column carrying the mask of the producing set.

§

Window

Window operation preserving every input row and appending one result column per window expression.

Fields

§windows: Vec<WindowExpr>
§

SetOperation

UNION, INTERSECT, or EXCEPT over two projection-compatible queries.

Fields

§operator: SetOperator
§all: bool
§

RecursiveCte

Materialized fixed-point evaluation for one directly self-recursive common table expression.

Fields

§name: String
§recursive_term: Box<LogicalPlan>
§union_all: bool
§

RecursiveReference

Read the current working-table delta of an enclosing RecursiveCte. The executor resolves this through an explicit per-query context.

Fields

§name: String
§

Sort

Sort operation (ORDER BY clause).

Sorts rows from the input plan based on sort expressions.

Fields

§input: Box<LogicalPlan>

Input plan to sort.

§order_by: Vec<SortExpr>

Sort expressions with direction.

§

DistinctOn

SELECT DISTINCT ON (expr, …) deduplication (issue #150).

Sorts the input by the complete effective sort specification and emits only the first row of each group of rows whose leading key_count sort keys compare equal (NULL keys compare equal to NULL, D5).

Invariants established by the planner (docs/sql-distinct-on.md):

  • order_by[..key_count] covers every deduplicated DISTINCT ON key (the user’s matching ORDER BY prefix plus implicit ASC NULLS LAST keys, D2/D3).
  • order_by[key_count..] carries the user’s ORDER BY tail followed by every input column as an ASC NULLS LAST tie-breaker, so the surviving row of each group never depends on physical input order (D4).
  • The node emits rows already ordered by the effective specification, so no additional Sort node is planned above it (D8).

Fields

§input: Box<LogicalPlan>

Input plan to deduplicate.

§key_count: usize

Number of leading order_by entries that form the distinctness key.

§order_by: Vec<SortExpr>

Complete effective sort specification (keys, tail, tie-breakers).

§

Limit

Limit operation (LIMIT/OFFSET/FETCH clause).

Limits the number of rows from the input plan. limit and offset are concrete values resolved at plan time, so the node can be carried by the distributed plan contract without re-evaluating expressions.

Fields

§input: Box<LogicalPlan>

Input plan to limit.

§limit: Option<u64>

Maximum number of rows to return.

§offset: Option<u64>

Number of rows to skip.

§ties: Option<Vec<SortExpr>>

FETCH … WITH TIES: after limit rows, keep emitting rows whose ORDER BY sort key equals the final emitted row’s key (peer rows). The keys are a copy of the Sort node directly beneath this Limit; None means plain ONLY/LIMIT semantics.

§

Insert

INSERT operation.

Inserts one or more rows into a table. When columns are omitted in the SQL statement, the Planner fills in all columns from TableMetadata in definition order.

Fields

§table: String

Target table name.

§columns: Vec<String>

Column names (always populated, never empty). If omitted in SQL, filled from TableMetadata.column_names().

§values: Vec<Vec<TypedExpr>>

Values to insert (one Vec per row, each value corresponds to a column).

§

InsertSelect

INSERT rows produced by a SELECT query.

Fields

§table: String

Target table name.

§columns: Vec<String>

Column names (always populated, never empty).

§source: Box<LogicalPlan>

Query that produces one row per inserted row.

§

Update

UPDATE operation.

Updates rows in a table that match an optional filter.

Fields

§table: String

Target table name.

§assignments: Vec<TypedAssignment>

Assignments (SET column = value).

§filter: Option<TypedExpr>

Optional filter predicate (WHERE clause).

§

Delete

DELETE operation.

Deletes rows from a table that match an optional filter.

Fields

§table: String

Target table name.

§filter: Option<TypedExpr>

Optional filter predicate (WHERE clause).

§

CreateTable

CREATE TABLE operation.

Creates a new table with the specified metadata.

Fields

§table: TableMetadata

Table metadata (name, columns, constraints).

§if_not_exists: bool

If true, don’t error if table already exists.

§with_options: Vec<(String, String)>

Raw WITH options to be validated during execution.

§

DropTable

DROP TABLE operation.

Drops an existing table.

Fields

§name: String

Table name to drop.

§if_exists: bool

If true, don’t error if table doesn’t exist.

§

CreateIndex

CREATE INDEX operation.

Creates a new index on a table column.

Fields

§index: IndexMetadata

Index metadata (name, table, column, method, options).

§if_not_exists: bool

If true, don’t error if index already exists.

§

DropIndex

DROP INDEX operation.

Drops an existing index.

Fields

§name: String

Index name to drop.

§if_exists: bool

If true, don’t error if index doesn’t exist.

Implementations§

Source§

impl LogicalPlan

Source

pub fn operation_name(&self) -> &'static str

Source

pub fn scan(table: String, projection: Projection) -> Self

Creates a new Scan plan.

Source

pub fn filter(input: LogicalPlan, predicate: TypedExpr) -> Self

Creates a new Filter plan.

Source

pub fn project(input: LogicalPlan, projection: Projection) -> Self

Creates a new Project plan.

Source

pub fn join( left: LogicalPlan, right: LogicalPlan, join_type: JoinType, condition: Option<TypedExpr>, using: Option<Vec<String>>, ) -> Self

Creates a new Join plan.

Source

pub fn aggregate( input: LogicalPlan, group_keys: Vec<TypedExpr>, aggregates: Vec<AggregateExpr>, having: Option<TypedExpr>, projection: Projection, ) -> Self

Creates a new Aggregate plan without grouping sets.

Source

pub fn sort(input: LogicalPlan, order_by: Vec<SortExpr>) -> Self

Creates a new Sort plan.

Source

pub fn distinct_on( input: LogicalPlan, key_count: usize, order_by: Vec<SortExpr>, ) -> Self

Creates a new DistinctOn plan.

Source

pub fn limit( input: LogicalPlan, limit: Option<u64>, offset: Option<u64>, ) -> Self

Creates a new Limit plan (plain ONLY/LIMIT semantics, no ties).

Source

pub fn insert( table: String, columns: Vec<String>, values: Vec<Vec<TypedExpr>>, ) -> Self

Creates a new Insert plan.

Source

pub fn update( table: String, assignments: Vec<TypedAssignment>, filter: Option<TypedExpr>, ) -> Self

Creates a new Update plan.

Source

pub fn delete(table: String, filter: Option<TypedExpr>) -> Self

Creates a new Delete plan.

Source

pub fn create_table( table: TableMetadata, if_not_exists: bool, with_options: Vec<(String, String)>, ) -> Self

Creates a new CreateTable plan.

Source

pub fn drop_table(name: String, if_exists: bool) -> Self

Creates a new DropTable plan.

Source

pub fn create_index(index: IndexMetadata, if_not_exists: bool) -> Self

Creates a new CreateIndex plan.

Source

pub fn drop_index(name: String, if_exists: bool) -> Self

Creates a new DropIndex plan.

Source

pub fn name(&self) -> &'static str

Returns the name of this plan variant.

Source

pub fn is_query(&self) -> bool

Returns true if this is a query plan (Scan, Filter, Sort, Limit).

Source

pub fn is_dml(&self) -> bool

Returns true if this is a DML plan (Insert, Update, Delete).

Source

pub fn is_ddl(&self) -> bool

Returns true if this is a DDL plan (CreateTable, DropTable, CreateIndex, DropIndex).

Source

pub fn input(&self) -> Option<&LogicalPlan>

Returns the input plan if this is a transformation (Filter, Aggregate, Sort, Limit).

Source

pub fn table_name(&self) -> Option<&str>

Returns the table name if this plan operates on a single table.

Source

pub fn contains_join(&self) -> bool

Returns whether this plan tree contains a JOIN boundary.

The normal local planner/executor continues to support JOIN. Consumers with a deliberately closed execution catalog (such as distributed reads) can use this structural fact to reject it before any transport is opened rather than trying to infer it from a table name.

Source

pub fn contains_set_operation(&self) -> bool

Returns whether this plan tree contains a set-operation boundary.

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> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, <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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more