Struct datafusion::execution::context::SessionState
source · pub struct SessionState { /* private fields */ }Expand description
Execution context for registering data sources and executing queries.
See SessionContext for a higher level API.
Note that there is no Default or new() for SessionState,
to avoid accidentally running queries or other operations without passing through
the SessionConfig or RuntimeEnv. See SessionContext.
Implementations§
source§impl SessionState
impl SessionState
sourcepub fn new_with_config_rt(
config: SessionConfig,
runtime: Arc<RuntimeEnv>
) -> Self
pub fn new_with_config_rt( config: SessionConfig, runtime: Arc<RuntimeEnv> ) -> Self
Returns new SessionState using the provided
SessionConfig and RuntimeEnv.
sourcepub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self
👎Deprecated since 32.0.0: Use SessionState::new_with_config_rt
pub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self
Returns new SessionState using the provided
SessionConfig and RuntimeEnv.
sourcepub fn new_with_config_rt_and_catalog_list(
config: SessionConfig,
runtime: Arc<RuntimeEnv>,
catalog_list: Arc<dyn CatalogList>
) -> Self
pub fn new_with_config_rt_and_catalog_list( config: SessionConfig, runtime: Arc<RuntimeEnv>, catalog_list: Arc<dyn CatalogList> ) -> Self
Returns new SessionState using the provided
SessionConfig, RuntimeEnv, and CatalogList
sourcepub fn with_config_rt_and_catalog_list(
config: SessionConfig,
runtime: Arc<RuntimeEnv>,
catalog_list: Arc<dyn CatalogList>
) -> Self
👎Deprecated since 32.0.0: Use SessionState::new_with_config_rt_and_catalog_list
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
SessionConfig and RuntimeEnv.
sourcepub fn with_session_id(self, session_id: String) -> Self
pub fn with_session_id(self, session_id: String) -> Self
Replace the random session id.
sourcepub fn with_query_planner(
self,
query_planner: Arc<dyn QueryPlanner + Send + Sync>
) -> Self
pub fn with_query_planner( self, query_planner: Arc<dyn QueryPlanner + Send + Sync> ) -> Self
Replace the default query planner
sourcepub fn with_analyzer_rules(
self,
rules: Vec<Arc<dyn AnalyzerRule + Send + Sync>>
) -> Self
pub fn with_analyzer_rules( self, rules: Vec<Arc<dyn AnalyzerRule + Send + Sync>> ) -> Self
Replace the analyzer rules
sourcepub fn with_optimizer_rules(
self,
rules: Vec<Arc<dyn OptimizerRule + Send + Sync>>
) -> Self
pub fn with_optimizer_rules( self, rules: Vec<Arc<dyn OptimizerRule + Send + Sync>> ) -> Self
Replace the optimizer rules
sourcepub fn with_physical_optimizer_rules(
self,
physical_optimizers: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>
) -> Self
pub fn with_physical_optimizer_rules( self, physical_optimizers: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>> ) -> Self
Replace the physical optimizer rules
sourcepub fn add_analyzer_rule(
self,
analyzer_rule: Arc<dyn AnalyzerRule + Send + Sync>
) -> Self
pub fn add_analyzer_rule( self, analyzer_rule: Arc<dyn AnalyzerRule + Send + Sync> ) -> Self
Adds a new AnalyzerRule
sourcepub fn add_optimizer_rule(
self,
optimizer_rule: Arc<dyn OptimizerRule + Send + Sync>
) -> Self
pub fn add_optimizer_rule( self, optimizer_rule: Arc<dyn OptimizerRule + Send + Sync> ) -> Self
Adds a new OptimizerRule
sourcepub fn add_physical_optimizer_rule(
self,
optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync>
) -> Self
pub fn add_physical_optimizer_rule( self, optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync> ) -> Self
Adds a new PhysicalOptimizerRule
sourcepub fn with_serializer_registry(
self,
registry: Arc<dyn SerializerRegistry>
) -> Self
pub fn with_serializer_registry( self, registry: Arc<dyn SerializerRegistry> ) -> Self
Replace the extension SerializerRegistry
sourcepub fn table_factories(&self) -> &HashMap<String, Arc<dyn TableProviderFactory>>
pub fn table_factories(&self) -> &HashMap<String, Arc<dyn TableProviderFactory>>
Get the table factories
sourcepub fn table_factories_mut(
&mut self
) -> &mut HashMap<String, Arc<dyn TableProviderFactory>>
pub fn table_factories_mut( &mut self ) -> &mut HashMap<String, Arc<dyn TableProviderFactory>>
Get the table factories
sourcepub fn sql_to_statement(&self, sql: &str, dialect: &str) -> Result<Statement>
pub fn sql_to_statement(&self, sql: &str, dialect: &str) -> Result<Statement>
Parse an SQL string into an DataFusion specific AST
Statement. See SessionContext::sql for running queries.
sourcepub fn resolve_table_references(
&self,
statement: &Statement
) -> Result<Vec<OwnedTableReference>>
pub fn resolve_table_references( &self, statement: &Statement ) -> Result<Vec<OwnedTableReference>>
Resolve all table references in the SQL statement.
sourcepub async fn statement_to_plan(
&self,
statement: Statement
) -> Result<LogicalPlan>
pub async fn statement_to_plan( &self, statement: Statement ) -> Result<LogicalPlan>
Convert an AST Statement into a LogicalPlan
sourcepub async fn create_logical_plan(&self, sql: &str) -> Result<LogicalPlan>
pub async fn create_logical_plan(&self, sql: &str) -> Result<LogicalPlan>
Creates a LogicalPlan from the provided SQL string. This
interface will plan any SQL DataFusion supports, including DML
like CREATE TABLE, and COPY (which can write to local
files.
See SessionContext::sql and
SessionContext::sql_with_options for a higher-level
interface that handles DDL and verification of allowed
statements.
sourcepub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan>
pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan>
Optimizes the logical plan by applying optimizer rules.
sourcepub async fn create_physical_plan(
&self,
logical_plan: &LogicalPlan
) -> Result<Arc<dyn ExecutionPlan>>
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.
This function will error for LogicalPlans such as catalog
DDL CREATE TABLE must be handled by another layer.
sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Return the session ID
sourcepub fn runtime_env(&self) -> &Arc<RuntimeEnv>
pub fn runtime_env(&self) -> &Arc<RuntimeEnv>
Return the runtime env
sourcepub fn execution_props(&self) -> &ExecutionProps
pub fn execution_props(&self) -> &ExecutionProps
Return the execution properties
sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
Return the SessionConfig
sourcepub fn physical_optimizers(
&self
) -> &[Arc<dyn PhysicalOptimizerRule + Send + Sync>]
pub fn physical_optimizers( &self ) -> &[Arc<dyn PhysicalOptimizerRule + Send + Sync>]
Return the physical optimizers
sourcepub fn config_options(&self) -> &ConfigOptions
pub fn config_options(&self) -> &ConfigOptions
return the configuration options
sourcepub fn task_ctx(&self) -> Arc<TaskContext>
pub fn task_ctx(&self) -> Arc<TaskContext>
Get a new TaskContext to run in this session
sourcepub fn catalog_list(&self) -> Arc<dyn CatalogList>
pub fn catalog_list(&self) -> Arc<dyn CatalogList>
Return catalog list
sourcepub fn scalar_functions(&self) -> &HashMap<String, Arc<ScalarUDF>>
pub fn scalar_functions(&self) -> &HashMap<String, Arc<ScalarUDF>>
Return reference to scalar_functions
sourcepub fn aggregate_functions(&self) -> &HashMap<String, Arc<AggregateUDF>>
pub fn aggregate_functions(&self) -> &HashMap<String, Arc<AggregateUDF>>
Return reference to aggregate_functions
sourcepub fn window_functions(&self) -> &HashMap<String, Arc<WindowUDF>>
pub fn window_functions(&self) -> &HashMap<String, Arc<WindowUDF>>
Return reference to window functions
sourcepub fn serializer_registry(&self) -> Arc<dyn SerializerRegistry>
pub fn serializer_registry(&self) -> Arc<dyn SerializerRegistry>
Return SerializerRegistry for extensions
Trait Implementations§
source§impl Clone for SessionState
impl Clone for SessionState
source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for SessionState
impl Debug for SessionState
source§impl From<&SessionState> for TaskContext
impl From<&SessionState> for TaskContext
Create a new task context instance from SessionState