LogicalPlan

Enum LogicalPlan 

Source
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:

  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§

§

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

§

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

§

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.

§

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.

§

Limit

Limit operation (LIMIT/OFFSET clause).

Limits the number of rows from the input plan.

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.

§

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

§

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 aggregate( input: LogicalPlan, group_keys: Vec<TypedExpr>, aggregates: Vec<AggregateExpr>, having: Option<TypedExpr>, ) -> Self

Creates a new Aggregate plan.

Source

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

Creates a new Sort plan.

Source

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

Creates a new Limit plan.

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.

Trait Implementations§

Source§

impl Clone for LogicalPlan

Source§

fn clone(&self) -> LogicalPlan

Returns a duplicate of the value. Read more
1.0.0 · 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> 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> 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.
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
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> MaybeSend for T
where T: Send,