pub enum LogicalPlan {
Show 34 variants
Scan {
table: Arc<Table>,
alias: Option<String>,
projection: Option<Vec<usize>>,
filter: Option<Expr>,
},
IndexScan {
table: Arc<Table>,
alias: Option<String>,
index: Index,
index_column: usize,
range: IndexRange,
residual_filter: Option<Expr>,
projection: Option<Vec<usize>>,
},
PkSeek {
table: Arc<Table>,
alias: Option<String>,
key_values: Vec<Expr>,
residual_filter: Option<Expr>,
projection: Option<Vec<usize>>,
},
PkRangeScan {
table: Arc<Table>,
alias: Option<String>,
range: IndexRange,
residual_filter: Option<Expr>,
projection: Option<Vec<usize>>,
},
Filter {
input: Box<LogicalPlan>,
predicate: Expr,
},
Project {
input: Box<LogicalPlan>,
exprs: Vec<(Expr, String)>,
},
Join {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
join_type: JoinType,
condition: Option<Expr>,
},
Aggregate {
input: Box<LogicalPlan>,
group_by: Vec<Expr>,
aggregates: Vec<(Expr, String)>,
},
Sort {
input: Box<LogicalPlan>,
order_by: Vec<(Expr, SortOrder)>,
},
Limit {
input: Box<LogicalPlan>,
limit: Option<usize>,
offset: usize,
},
Distinct {
input: Box<LogicalPlan>,
},
Insert {
table: Arc<Table>,
columns: Vec<String>,
values: Vec<Vec<Expr>>,
},
Update {
table: Arc<Table>,
assignments: Vec<(String, Expr)>,
filter: Option<Expr>,
},
Delete {
table: Arc<Table>,
filter: Option<Expr>,
},
CreateTable {
table: Table,
},
DropTable {
name: String,
if_exists: bool,
},
EmptyRelation,
Explain {
input: Box<LogicalPlan>,
verbose: bool,
analyze: bool,
},
Window {
input: Box<LogicalPlan>,
window_exprs: Vec<(Expr, String)>,
},
AlterTable {
table_name: String,
operations: Vec<AlterTableOp>,
},
WithCte {
ctes: Vec<CommonTableExpression>,
query: Box<LogicalPlan>,
},
CteScan {
cte_name: String,
alias: Option<String>,
columns: Vec<String>,
},
SubqueryScan {
subquery: Box<LogicalPlan>,
subquery_id: usize,
alias: Option<String>,
},
SemiJoin {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
condition: Option<Expr>,
positive: bool,
},
AntiJoin {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
condition: Option<Expr>,
},
Grant {
privileges: Permissions,
table: Option<String>,
grantee: String,
},
Revoke {
privileges: Permissions,
table: Option<String>,
grantee: String,
},
ShowGrants {
target: ShowGrantsTarget,
},
Union {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
all: bool,
},
Intersect {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
all: bool,
},
Except {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
all: bool,
},
CreateView {
name: String,
query: Box<LogicalPlan>,
query_sql: String,
columns: Vec<String>,
},
DropView {
name: String,
if_exists: bool,
},
CreateIndex {
index_name: String,
table_name: String,
columns: Vec<String>,
unique: bool,
},
}Expand description
Logical plan - represents a query as a tree of relational operators
Variants§
Scan
Scan a table
IndexScan
Index scan - uses an index for efficient lookups This provides 100-1000x speedup for indexed queries
Fields
range: IndexRangeRange to scan in the index
PkSeek
Direct primary key lookup - O(log N) instead of O(N) scan Used when ALL primary key columns have equality predicates
Fields
PkRangeScan
Direct primary key range scan - O(range_size) instead of O(N) Used when PK column has range predicates (>=, >, <=, <)
Fields
range: IndexRangeRange bounds for PK scan
Filter
Filter rows
Project
Project columns
Join
Join two inputs
Aggregate
Aggregate
Sort
Sort
Limit
Limit output rows
Distinct
Distinct
Fields
input: Box<LogicalPlan>Insert
Insert rows
Update
Update rows
Delete
Delete rows
CreateTable
Create table
DropTable
Drop table
EmptyRelation
Empty relation (for queries with no FROM)
Explain
Explain plan - shows query execution plan with cost estimates
Fields
input: Box<LogicalPlan>The plan to explain
Window
Window function evaluation
Fields
input: Box<LogicalPlan>Input plan
AlterTable
Alter table schema
Fields
operations: Vec<AlterTableOp>Operations to perform
WithCte
Common Table Expression (CTE) - WITH clause Materializes CTE results and makes them available as virtual tables
Fields
ctes: Vec<CommonTableExpression>CTE definitions (name, columns, plan, is_recursive)
query: Box<LogicalPlan>The main query that uses the CTEs
CteScan
Scan a CTE by name
Fields
SubqueryScan
Subquery scan - executes a subquery and provides its results
Fields
subquery: Box<LogicalPlan>The subquery plan
SemiJoin
Semi-join - optimized execution for EXISTS/IN subqueries Returns rows from left where at least one matching row exists in right
AntiJoin
Anti-join - returns rows from left where NO matching row exists in right Used for NOT IN / NOT EXISTS optimization
Grant
Grant permissions on a table to an API key (v0.4.0)
Fields
privileges: PermissionsPermissions to grant (SELECT, INSERT, UPDATE, DELETE, ALL)
Revoke
Revoke permissions from an API key (v0.4.0)
Fields
privileges: PermissionsPermissions to revoke (SELECT, INSERT, UPDATE, DELETE, ALL)
ShowGrants
Show grants for a table or API key (v0.4.0)
Fields
target: ShowGrantsTargetTarget of SHOW GRANTS query
Union
UNION / UNION ALL - combines results of two queries
Intersect
INTERSECT / INTERSECT ALL - returns rows common to both queries
Except
EXCEPT / EXCEPT ALL - returns rows in left but not in right
CreateView
CREATE VIEW - stores a named query definition
Fields
query: Box<LogicalPlan>DropView
DROP VIEW
CreateIndex
CREATE INDEX
Implementations§
Source§impl LogicalPlan
impl LogicalPlan
Sourcepub fn output_columns(&self) -> Vec<String>
pub fn output_columns(&self) -> Vec<String>
Get output column names
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 moreAuto Trait Implementations§
impl Freeze for LogicalPlan
impl RefUnwindSafe for LogicalPlan
impl Send for LogicalPlan
impl Sync for LogicalPlan
impl Unpin for LogicalPlan
impl UnsafeUnpin for LogicalPlan
impl UnwindSafe for LogicalPlan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.