RuntimeContext

Struct RuntimeContext 

Source
pub struct RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync,
{ /* private fields */ }
Expand description

In-memory execution context shared by plan-based queries.

Important: “lazy loading” here refers to table metadata only (schema, executor-side column descriptors, and a small next-row-id counter). We do NOT eagerly load or materialize the table’s row data into memory. All row/column data remains on the ColumnStore and is streamed in chunks during query execution. This keeps the memory footprint low even for very large tables.

Typical resource usage:

  • Metadata per table: ~100s of bytes to a few KB (schema + field ids)
  • ExecutorTable struct: small (handles + counters)
  • Actual table rows: streamed from disk in chunks (never fully resident)

Implementations§

Source§

impl<P> RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync,

Source

pub fn rename_column( &self, table_name: &str, old_column_name: &str, new_column_name: &str, ) -> Result<()>

Renames a column in a table by delegating to the catalog layer.

Source

pub fn alter_column_type( &self, table_name: &str, column_name: &str, new_data_type_sql: &str, ) -> Result<()>

Alters the data type of a column by delegating to the catalog layer.

Source

pub fn drop_column(&self, table_name: &str, column_name: &str) -> Result<()>

Drops a column from a table by delegating to the catalog layer.

Source§

impl<P> RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync + 'static,

Source

pub fn lookup_table( &self, canonical_name: &str, ) -> Result<Arc<ExecutorTable<P>>>

Looks up a table in the executor cache, lazily loading it from metadata if not already cached. This is the primary method for obtaining table references for query execution.

Source§

impl<P> RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync,

Source

pub fn create_table<C, I>( self: &Arc<Self>, name: &str, columns: I, ) -> Result<RuntimeTableHandle<P>>
where C: IntoPlanColumnSpec, I: IntoIterator<Item = C>,

Create a new table with the given columns.

Public API method for table creation.

Source

pub fn create_table_if_not_exists<C, I>( self: &Arc<Self>, name: &str, columns: I, ) -> Result<RuntimeTableHandle<P>>
where C: IntoPlanColumnSpec, I: IntoIterator<Item = C>,

Create a new table if it doesn’t already exist.

Public API method for conditional table creation.

Source

pub fn create_table_builder( &self, name: &str, ) -> RuntimeCreateTableBuilder<'_, P>

Creates a fluent builder for defining and creating a new table with columns and constraints.

Public API method for advanced table creation with constraints.

Source§

impl<P> RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync,

Source

pub fn is_table_marked_dropped(&self, canonical_name: &str) -> bool

Check if a table is marked as dropped.

Source§

impl<P> RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync + 'static,

Source

pub fn new(pager: Arc<P>) -> Self

Source

pub fn new_with_catalog(pager: Arc<P>, catalog: Arc<TableCatalog>) -> Self

Source

pub fn txn_manager(&self) -> Arc<TxnIdManager>

Return the transaction ID manager shared with sessions.

Source

pub fn store(&self) -> &Arc<ColumnStore<P>>

Return the column store for catalog operations.

Source

pub fn with_fallback_lookup(self, fallback: Arc<RuntimeContext<P>>) -> Self

Set a fallback context for cross-pager table lookups. The fallback uses BoxedPager to enable access across different underlying pager types (e.g., temporary MemPager can fall back to persistent disk pager).

Source

pub fn register_type(&self, name: String, data_type: DataType)

Register a custom type alias (CREATE TYPE/DOMAIN).

Source

pub fn drop_type(&self, name: &str) -> Result<()>

Drop a custom type alias (DROP TYPE/DOMAIN).

Source

pub fn ensure_next_table_id_at_least(&self, minimum: TableId) -> Result<()>

Ensure the catalog’s next_table_id counter is at least minimum.

Source

pub fn create_view( self: &Arc<Self>, display_name: &str, view_definition: String, select_plan: SelectPlan, if_not_exists: bool, ) -> Result<()>

Create a view by executing its SELECT definition to derive projected columns and persisting the metadata into the catalog. The view is registered as a catalog entry with column names so subsequent binding can succeed without reparsing the stored SQL in higher layers.

Source

pub fn create_trigger( self: &Arc<Self>, trigger_display_name: &str, canonical_trigger_name: &str, table_display_name: &str, canonical_table_name: &str, timing: TriggerTimingMeta, event: TriggerEventMeta, for_each_row: bool, condition: Option<String>, body_sql: String, if_not_exists: bool, ) -> Result<bool>

Source

pub fn drop_trigger( self: &Arc<Self>, trigger_display_name: &str, canonical_trigger_name: &str, table_hint_display: Option<&str>, table_hint_canonical: Option<&str>, if_exists: bool, ) -> Result<bool>

Source

pub fn view_definition(&self, canonical_name: &str) -> Result<Option<String>>

Return the stored SQL definition for a view, if it exists.

Source

pub fn is_view(&self, table_id: TableId) -> Result<bool>

Check if a table is actually a view by looking at its metadata. Returns true if the table exists and has a view_definition.

Source

pub fn drop_view(&self, name: &str, if_exists: bool) -> Result<()>

Drop a view, ignoring missing views when if_exists is true.

Source

pub fn resolve_type(&self, data_type: &DataType) -> DataType

Resolve a type name to its base DataType, recursively following aliases.

Source

pub fn persist_next_txn_id(&self, next_txn_id: TxnId) -> Result<()>

Persist the next_txn_id to the catalog.

Source

pub fn default_snapshot(&self) -> TransactionSnapshot

Construct the default snapshot for auto-commit operations.

Source

pub fn table_catalog(&self) -> Arc<TableCatalog>

Get the table catalog for schema and table name management.

Source

pub fn catalog(&self) -> &CatalogManager<P>

Access the catalog manager for type registry, view management, and metadata operations.

Source

pub fn table(self: &Arc<Self>, name: &str) -> Result<RuntimeTableHandle<P>>

Get a handle to an existing table by name.

Source

pub fn table_names(self: &Arc<Self>) -> Vec<String>

Create a table with explicit column definitions - Programmatic API.

This is a convenience method for programmatically creating tables with explicit column definitions. Use this when you’re writing Rust code that needs to create tables directly, rather than executing SQL.

§When to use create_table vs CatalogDdl::create_table

Use create_table:

  • You’re writing Rust code (not parsing SQL)
  • You have explicit column definitions
  • You want a simple, ergonomic API: ctx.create_table("users", vec![...])
  • You want a RuntimeTableHandle to work with immediately
  • Does NOT support: CREATE TABLE AS SELECT, foreign keys, namespaces

Use CatalogDdl::create_table:

  • You’re implementing SQL execution (already have a parsed CreateTablePlan)
  • You need CREATE TABLE AS SELECT support
  • You need foreign key constraints
  • You need namespace support (temporary tables)
  • You need IF NOT EXISTS / OR REPLACE semantics
  • You’re working within the transaction system
§Usage Comparison

Programmatic API (this method):

  • ctx.create_table("users", vec![("id", DataType::Int64, false), ...])?
  • Returns RuntimeTableHandle for immediate use
  • Simple, ergonomic, no plan construction needed

SQL execution API (CatalogDdl::create_table):

  • Construct a CreateTablePlan with all SQL features
  • Delegates to the CatalogDdl trait for catalog-aware creation
  • Support for CTAS, foreign keys, namespaces, transactions
  • Returns RuntimeStatementResult for consistency with other SQL operations
§Returns

Returns a RuntimeTableHandle that provides immediate access to the table. Use this for further programmatic operations on the table. Returns all table names currently registered in the catalog.

Source§

impl RuntimeContext<BoxedPager>

Source

pub fn create_session(self: &Arc<Self>) -> RuntimeSession

Create a new session for transaction management. Each session can have its own independent transaction.

Trait Implementations§

Source§

impl<P> CatalogDdl for RuntimeContext<P>
where P: Pager<Blob = EntryHandle> + Send + Sync + 'static,

Source§

type CreateTableOutput = RuntimeStatementResult<P>

Output of executing a CREATE TABLE plan.
Source§

type DropTableOutput = ()

Output of executing a DROP TABLE plan.
Source§

type RenameTableOutput = ()

Output of executing a table rename.
Source§

type AlterTableOutput = RuntimeStatementResult<P>

Output of executing an ALTER TABLE plan.
Source§

type CreateIndexOutput = RuntimeStatementResult<P>

Output of executing a CREATE INDEX plan.
Source§

type DropIndexOutput = Option<SingleColumnIndexDescriptor>

Output of executing a DROP INDEX plan.
Source§

fn create_table(&self, plan: CreateTablePlan) -> Result<Self::CreateTableOutput>

Creates a table described by the given plan.
Source§

fn drop_table(&self, plan: DropTablePlan) -> Result<Self::DropTableOutput>

Drops a table identified by the given plan.
Source§

fn rename_table(&self, plan: RenameTablePlan) -> Result<Self::RenameTableOutput>

Renames a table using the provided plan.
Source§

fn alter_table(&self, plan: AlterTablePlan) -> Result<Self::AlterTableOutput>

Alters a table using the provided plan.
Source§

fn create_index(&self, plan: CreateIndexPlan) -> Result<Self::CreateIndexOutput>

Creates an index described by the given plan.
Source§

fn drop_index(&self, plan: DropIndexPlan) -> Result<Self::DropIndexOutput>

Drops a single-column index described by the given plan, returning metadata about the index when it existed.
Source§

fn create_view(&self, _plan: CreateViewPlan) -> Result<()>

Creates a view described by the given plan.
Source§

fn drop_view(&self, plan: DropViewPlan) -> Result<()>

Drops a view identified by the given plan.

Auto Trait Implementations§

§

impl<P> !Freeze for RuntimeContext<P>

§

impl<P> RefUnwindSafe for RuntimeContext<P>
where P: RefUnwindSafe,

§

impl<P> Send for RuntimeContext<P>

§

impl<P> Sync for RuntimeContext<P>

§

impl<P> Unpin for RuntimeContext<P>

§

impl<P> UnwindSafe for RuntimeContext<P>
where P: RefUnwindSafe,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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,