pub enum LogicalPlan {
Scan {
table: String,
projection: Projection,
},
Filter {
input: Box<LogicalPlan>,
predicate: TypedExpr,
},
Aggregate {
input: Box<LogicalPlan>,
group_keys: Vec<TypedExpr>,
aggregates: Vec<AggregateExpr>,
having: Option<TypedExpr>,
},
Sort {
input: Box<LogicalPlan>,
order_by: Vec<SortExpr>,
},
Limit {
input: Box<LogicalPlan>,
limit: Option<u64>,
offset: Option<u64>,
},
Insert {
table: String,
columns: Vec<String>,
values: Vec<Vec<TypedExpr>>,
},
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§
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).
Filter
Filter operation (WHERE clause).
Filters rows from the input plan based on a predicate.
Fields
input: Box<LogicalPlan>Input plan to filter.
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.
Sort
Sort operation (ORDER BY clause).
Sorts rows from the input plan based on sort expressions.
Fields
input: Box<LogicalPlan>Input plan to sort.
Limit
Limit operation (LIMIT/OFFSET clause).
Limits the number of rows from the input plan.
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
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 aggregate(
input: LogicalPlan,
group_keys: Vec<TypedExpr>,
aggregates: Vec<AggregateExpr>,
having: Option<TypedExpr>,
) -> Self
pub fn aggregate( input: LogicalPlan, group_keys: Vec<TypedExpr>, aggregates: Vec<AggregateExpr>, having: Option<TypedExpr>, ) -> Self
Creates a new Aggregate plan.
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 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.
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.
Trait Implementations§
Source§impl Clone for LogicalPlan
impl Clone for LogicalPlan
Source§fn clone(&self) -> LogicalPlan
fn clone(&self) -> LogicalPlan
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more