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:
- Query Plans: Read operations (Scan, Filter, Sort, Limit)
- DML Plans: Data modification (Insert, Update, Delete)
- DDL Plans: Schema modification (CreateTable, DropTable, CreateIndex, DropIndex)
Variants§
Pragma
Runtime configuration or statistics operation.
Scan
Table scan operation.
Scans all rows from a table with the specified projection. This is typically the leaf node of query plans.
Fields
projection: ProjectionColumns to project (after wildcard expansion).
Values
Inline VALUES rows evaluated once per output row.
Fields
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.
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.
Join
JOIN operation.
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.
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: TableFunctionKindWhich function this node evaluates.
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.
aggregates: Vec<AggregateExpr>Aggregate expressions to compute.
projection: ProjectionProjection 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.
SetOperation
UNION, INTERSECT, or EXCEPT over two projection-compatible queries.
RecursiveCte
Materialized fixed-point evaluation for one directly self-recursive common table expression.
Fields
anchor: Box<LogicalPlan>recursive_term: Box<LogicalPlan>schema: Vec<ColumnMetadata>limits: RecursiveCteLimitsRecursiveReference
Read the current working-table delta of an enclosing RecursiveCte.
The executor resolves this through an explicit per-query context.
Sort
Sort operation (ORDER BY clause).
Sorts rows from the input plan based on sort expressions.
Fields
input: Box<LogicalPlan>Input plan to sort.
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.
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.
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
InsertSelect
INSERT rows produced by a SELECT query.
Fields
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
assignments: Vec<TypedAssignment>Assignments (SET column = value).
Delete
DELETE operation.
Deletes rows from a table that match an optional filter.
Fields
CreateTable
CREATE TABLE operation.
Creates a new table with the specified metadata.
Fields
table: TableMetadataTable metadata (name, columns, constraints).
DropTable
DROP TABLE operation.
Drops an existing table.
CreateIndex
CREATE INDEX operation.
Creates a new index on a table column.
Fields
index: IndexMetadataIndex metadata (name, table, column, method, options).
DropIndex
DROP INDEX operation.
Drops an existing index.
Implementations§
Source§impl LogicalPlan
impl LogicalPlan
pub fn operation_name(&self) -> &'static str
Sourcepub fn scan(table: String, projection: Projection) -> Self
pub fn scan(table: String, projection: Projection) -> Self
Creates a new Scan plan.
Sourcepub fn filter(input: LogicalPlan, predicate: TypedExpr) -> Self
pub fn filter(input: LogicalPlan, predicate: TypedExpr) -> Self
Creates a new Filter plan.
Sourcepub fn project(input: LogicalPlan, projection: Projection) -> Self
pub fn project(input: LogicalPlan, projection: Projection) -> Self
Creates a new Project plan.
Sourcepub fn join(
left: LogicalPlan,
right: LogicalPlan,
join_type: JoinType,
condition: Option<TypedExpr>,
using: Option<Vec<String>>,
) -> Self
pub fn join( left: LogicalPlan, right: LogicalPlan, join_type: JoinType, condition: Option<TypedExpr>, using: Option<Vec<String>>, ) -> Self
Creates a new Join plan.
Sourcepub fn aggregate(
input: LogicalPlan,
group_keys: Vec<TypedExpr>,
aggregates: Vec<AggregateExpr>,
having: Option<TypedExpr>,
projection: Projection,
) -> Self
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.
Sourcepub fn sort(input: LogicalPlan, order_by: Vec<SortExpr>) -> Self
pub fn sort(input: LogicalPlan, order_by: Vec<SortExpr>) -> Self
Creates a new Sort plan.
Sourcepub fn distinct_on(
input: LogicalPlan,
key_count: usize,
order_by: Vec<SortExpr>,
) -> Self
pub fn distinct_on( input: LogicalPlan, key_count: usize, order_by: Vec<SortExpr>, ) -> Self
Creates a new DistinctOn plan.
Sourcepub fn limit(
input: LogicalPlan,
limit: Option<u64>,
offset: Option<u64>,
) -> Self
pub fn limit( input: LogicalPlan, limit: Option<u64>, offset: Option<u64>, ) -> Self
Creates a new Limit plan (plain ONLY/LIMIT semantics, no ties).
Sourcepub fn insert(
table: String,
columns: Vec<String>,
values: Vec<Vec<TypedExpr>>,
) -> Self
pub fn insert( table: String, columns: Vec<String>, values: Vec<Vec<TypedExpr>>, ) -> Self
Creates a new Insert plan.
Sourcepub fn update(
table: String,
assignments: Vec<TypedAssignment>,
filter: Option<TypedExpr>,
) -> Self
pub fn update( table: String, assignments: Vec<TypedAssignment>, filter: Option<TypedExpr>, ) -> Self
Creates a new Update plan.
Sourcepub fn create_table(
table: TableMetadata,
if_not_exists: bool,
with_options: Vec<(String, String)>,
) -> Self
pub fn create_table( table: TableMetadata, if_not_exists: bool, with_options: Vec<(String, String)>, ) -> Self
Creates a new CreateTable plan.
Sourcepub fn drop_table(name: String, if_exists: bool) -> Self
pub fn drop_table(name: String, if_exists: bool) -> Self
Creates a new DropTable plan.
Sourcepub fn create_index(index: IndexMetadata, if_not_exists: bool) -> Self
pub fn create_index(index: IndexMetadata, if_not_exists: bool) -> Self
Creates a new CreateIndex plan.
Sourcepub fn drop_index(name: String, if_exists: bool) -> Self
pub fn drop_index(name: String, if_exists: bool) -> Self
Creates a new DropIndex plan.
Sourcepub fn is_query(&self) -> bool
pub fn is_query(&self) -> bool
Returns true if this is a query plan (Scan, Filter, Sort, Limit).
Sourcepub fn is_ddl(&self) -> bool
pub fn is_ddl(&self) -> bool
Returns true if this is a DDL plan (CreateTable, DropTable, CreateIndex, DropIndex).
Sourcepub fn input(&self) -> Option<&LogicalPlan>
pub fn input(&self) -> Option<&LogicalPlan>
Returns the input plan if this is a transformation (Filter, Aggregate, Sort, Limit).
Sourcepub fn table_name(&self) -> Option<&str>
pub fn table_name(&self) -> Option<&str>
Returns the table name if this plan operates on a single table.
Sourcepub fn contains_join(&self) -> bool
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.
Sourcepub fn contains_set_operation(&self) -> bool
pub fn contains_set_operation(&self) -> bool
Returns whether this plan tree contains a set-operation boundary.
Trait Implementations§
Source§impl Clone for LogicalPlan
impl Clone for LogicalPlan
Source§fn clone(&self) -> LogicalPlan
fn clone(&self) -> LogicalPlan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more