pub struct SessionState { /* private fields */ }
Expand description

Execution context for registering data sources and executing queries

Implementations§

source§

impl SessionState

source

pub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self

Returns new SessionState using the provided SessionConfig and RuntimeEnv.

source

pub fn with_config_rt_and_catalog_list( config: SessionConfig, runtime: Arc<RuntimeEnv>, catalog_list: Arc<dyn CatalogList> ) -> Self

Returns new SessionState using the provided configuration, runtime and catalog list.

source

pub fn with_session_id(self, session_id: String) -> Self

Replace the random session id.

source

pub fn with_query_planner( self, query_planner: Arc<dyn QueryPlanner + Send + Sync> ) -> Self

Replace the default query planner

source

pub fn with_analyzer_rules( self, rules: Vec<Arc<dyn AnalyzerRule + Send + Sync>> ) -> Self

Replace the analyzer rules

source

pub fn with_optimizer_rules( self, rules: Vec<Arc<dyn OptimizerRule + Send + Sync>> ) -> Self

Replace the optimizer rules

source

pub fn with_physical_optimizer_rules( self, physical_optimizers: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>> ) -> Self

Replace the physical optimizer rules

source

pub fn add_analyzer_rule( self, analyzer_rule: Arc<dyn AnalyzerRule + Send + Sync> ) -> Self

Adds a new AnalyzerRule

source

pub fn add_optimizer_rule( self, optimizer_rule: Arc<dyn OptimizerRule + Send + Sync> ) -> Self

Adds a new OptimizerRule

source

pub fn add_physical_optimizer_rule( self, optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync> ) -> Self

source

pub fn with_serializer_registry( self, registry: Arc<dyn SerializerRegistry> ) -> Self

Replace the extension SerializerRegistry

source

pub fn table_factories(&self) -> &HashMap<String, Arc<dyn TableProviderFactory>>

Get the table factories

source

pub fn table_factories_mut( &mut self ) -> &mut HashMap<String, Arc<dyn TableProviderFactory>>

Get the table factories

source

pub fn sql_to_statement(&self, sql: &str, dialect: &str) -> Result<Statement>

Convert a SQL string into an AST Statement

source

pub fn resolve_table_references( &self, statement: &Statement ) -> Result<Vec<OwnedTableReference>>

Resolve all table references in the SQL statement.

source

pub async fn statement_to_plan( &self, statement: Statement ) -> Result<LogicalPlan>

Convert an AST Statement into a LogicalPlan

source

pub async fn create_logical_plan(&self, sql: &str) -> Result<LogicalPlan>

Creates a LogicalPlan from the provided SQL string

See SessionContext::sql for a higher-level interface that also handles DDL

source

pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan>

Optimizes the logical plan by applying optimizer rules.

source

pub async fn create_physical_plan( &self, logical_plan: &LogicalPlan ) -> Result<Arc<dyn ExecutionPlan>>

Creates a physical plan from a logical plan.

Note: this first calls Self::optimize on the provided plan

source

pub fn session_id(&self) -> &str

Return the session ID

source

pub fn runtime_env(&self) -> &Arc<RuntimeEnv>

Return the runtime env

source

pub fn execution_props(&self) -> &ExecutionProps

Return the execution properties

source

pub fn config(&self) -> &SessionConfig

Return the SessionConfig

source

pub fn physical_optimizers( &self ) -> &[Arc<dyn PhysicalOptimizerRule + Send + Sync>]

Return the physical optimizers

source

pub fn config_options(&self) -> &ConfigOptions

return the configuration options

source

pub fn task_ctx(&self) -> Arc<TaskContext>

Get a new TaskContext to run in this session

source

pub fn catalog_list(&self) -> Arc<dyn CatalogList>

Return catalog list

source

pub fn scalar_functions(&self) -> &HashMap<String, Arc<ScalarUDF>>

Return reference to scalar_functions

source

pub fn aggregate_functions(&self) -> &HashMap<String, Arc<AggregateUDF>>

Return reference to aggregate_functions

source

pub fn window_functions(&self) -> &HashMap<String, Arc<WindowUDF>>

Return reference to window functions

source

pub fn serializer_registry(&self) -> Arc<dyn SerializerRegistry>

Return SerializerRegistry for extensions

source

pub fn version(&self) -> &str

Return version of the cargo package that produced this query

Trait Implementations§

source§

impl Clone for SessionState

source§

fn clone(&self) -> SessionState

Returns a copy 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 SessionState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&SessionState> for TaskContext

Create a new task context instance from SessionState

source§

fn from(state: &SessionState) -> Self

Converts to this type from the input type.
source§

impl FunctionRegistry for SessionState

source§

fn udfs(&self) -> HashSet<String>

Set of all available udfs.
source§

fn udf(&self, name: &str) -> Result<Arc<ScalarUDF>>

Returns a reference to the udf named name.
source§

fn udaf(&self, name: &str) -> Result<Arc<AggregateUDF>>

Returns a reference to the udaf named name.
source§

fn udwf(&self, name: &str) -> Result<Arc<WindowUDF>>

Returns a reference to the udwf named name.
source§

impl OptimizerConfig for SessionState

source§

fn query_execution_start_time(&self) -> DateTime<Utc>

Return the time at which the query execution started. This time is used as the value for now()
source§

fn alias_generator(&self) -> Arc<AliasGenerator>

Return alias generator used to generate unique aliases for subqueries
source§

fn options(&self) -> &ConfigOptions

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V