pub struct ExecutionContext<'a> {
pub schema: &'a CombinedSchema,
pub database: &'a Database,
pub outer_row: Option<&'a Row>,
pub outer_schema: Option<&'a CombinedSchema>,
pub procedural_context: Option<&'a ExecutionContext>,
pub cte_context: Option<&'a HashMap<String, CteResult>>,
pub window_mapping: Option<&'a HashMap<WindowFunctionKey, usize>>,
}Expand description
Execution context that bundles all information needed for query execution.
This struct consolidates the various optional contexts (outer row, procedural, CTE, windows) that were previously passed separately, reducing the number of evaluator constructor variants needed.
§Example
let ctx = ExecutionContext::new(schema, database)
.with_cte_context(cte_results)
.with_outer_context(outer_row, outer_schema);
let evaluator = ctx.create_evaluator();Fields§
§schema: &'a CombinedSchemaThe combined schema for column resolution
database: &'a DatabaseDatabase reference for table access and subqueries
outer_row: Option<&'a Row>Optional outer row for correlated subqueries
outer_schema: Option<&'a CombinedSchema>Optional outer schema for correlated subqueries
procedural_context: Option<&'a ExecutionContext>Optional procedural context for stored procedures/functions
cte_context: Option<&'a HashMap<String, CteResult>>Optional CTE context for WITH clause results
window_mapping: Option<&'a HashMap<WindowFunctionKey, usize>>Optional window function mapping
Implementations§
Source§impl<'a> ExecutionContext<'a>
impl<'a> ExecutionContext<'a>
Sourcepub fn new(schema: &'a CombinedSchema, database: &'a Database) -> Self
pub fn new(schema: &'a CombinedSchema, database: &'a Database) -> Self
Create a new execution context with required parameters.
§Arguments
schema- The combined schema for column resolutiondatabase- Database reference for table access
Sourcepub fn with_outer_context(
self,
outer_row: &'a Row,
outer_schema: &'a CombinedSchema,
) -> Self
pub fn with_outer_context( self, outer_row: &'a Row, outer_schema: &'a CombinedSchema, ) -> Self
Add outer context for correlated subqueries.
§Arguments
outer_row- The current row from the outer queryouter_schema- The schema of the outer query
Sourcepub fn with_procedural_context(self, proc_ctx: &'a ExecutionContext) -> Self
pub fn with_procedural_context(self, proc_ctx: &'a ExecutionContext) -> Self
Add procedural context for stored procedures/functions.
§Arguments
proc_ctx- The procedural execution context
Sourcepub fn with_cte_context(self, cte_ctx: &'a HashMap<String, CteResult>) -> Self
pub fn with_cte_context(self, cte_ctx: &'a HashMap<String, CteResult>) -> Self
Sourcepub fn with_window_mapping(
self,
window_mapping: &'a HashMap<WindowFunctionKey, usize>,
) -> Self
pub fn with_window_mapping( self, window_mapping: &'a HashMap<WindowFunctionKey, usize>, ) -> Self
Add window function mapping.
§Arguments
window_mapping- Map of window function keys to result column indices
Sourcepub fn create_evaluator(&self) -> CombinedExpressionEvaluator<'a>
pub fn create_evaluator(&self) -> CombinedExpressionEvaluator<'a>
Create a CombinedExpressionEvaluator with all the context from this struct.
This replaces the many constructor variants like:
with_database()with_database_and_cte()with_database_and_outer_context()with_database_and_outer_context_and_cte()with_database_and_procedural_context()with_database_and_procedural_context_and_cte()with_database_and_windows()with_database_and_windows_and_cte()
By using a builder pattern, we consolidate all 8+ variants into a single method.
Sourcepub fn has_outer_context(&self) -> bool
pub fn has_outer_context(&self) -> bool
Check if this context has outer context (for correlated subqueries).
Sourcepub fn has_cte_context(&self) -> bool
pub fn has_cte_context(&self) -> bool
Check if this context has CTE context.
Sourcepub fn has_procedural_context(&self) -> bool
pub fn has_procedural_context(&self) -> bool
Check if this context has procedural context.
Auto Trait Implementations§
impl<'a> Freeze for ExecutionContext<'a>
impl<'a> !RefUnwindSafe for ExecutionContext<'a>
impl<'a> Send for ExecutionContext<'a>
impl<'a> Sync for ExecutionContext<'a>
impl<'a> Unpin for ExecutionContext<'a>
impl<'a> !UnwindSafe for ExecutionContext<'a>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more