pub struct SessionStateBuilder {Show 23 fields
session_id: Option<String>,
analyzer: Option<Analyzer>,
expr_planners: Option<Vec<Arc<dyn ExprPlanner>>>,
type_planner: Option<Arc<dyn TypePlanner>>,
optimizer: Option<Optimizer>,
physical_optimizers: Option<PhysicalOptimizer>,
query_planner: Option<Arc<dyn QueryPlanner + Send + Sync>>,
catalog_list: Option<Arc<dyn CatalogProviderList>>,
table_functions: Option<HashMap<String, Arc<TableFunction>>>,
scalar_functions: Option<Vec<Arc<ScalarUDF>>>,
aggregate_functions: Option<Vec<Arc<AggregateUDF>>>,
window_functions: Option<Vec<Arc<WindowUDF>>>,
serializer_registry: Option<Arc<dyn SerializerRegistry>>,
file_formats: Option<Vec<Arc<dyn FileFormatFactory>>>,
config: Option<SessionConfig>,
table_options: Option<TableOptions>,
execution_props: Option<ExecutionProps>,
table_factories: Option<HashMap<String, Arc<dyn TableProviderFactory>>>,
runtime_env: Option<Arc<RuntimeEnv>>,
function_factory: Option<Arc<dyn FunctionFactory>>,
analyzer_rules: Option<Vec<Arc<dyn AnalyzerRule + Send + Sync>>>,
optimizer_rules: Option<Vec<Arc<dyn OptimizerRule + Send + Sync>>>,
physical_optimizer_rules: Option<Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>>,
}Expand description
A builder to be used for building SessionState’s. Defaults will
be used for all values unless explicitly provided.
See example on SessionState
Fields§
§session_id: Option<String>§analyzer: Option<Analyzer>§expr_planners: Option<Vec<Arc<dyn ExprPlanner>>>§type_planner: Option<Arc<dyn TypePlanner>>§optimizer: Option<Optimizer>§physical_optimizers: Option<PhysicalOptimizer>§query_planner: Option<Arc<dyn QueryPlanner + Send + Sync>>§catalog_list: Option<Arc<dyn CatalogProviderList>>§table_functions: Option<HashMap<String, Arc<TableFunction>>>§scalar_functions: Option<Vec<Arc<ScalarUDF>>>§aggregate_functions: Option<Vec<Arc<AggregateUDF>>>§window_functions: Option<Vec<Arc<WindowUDF>>>§serializer_registry: Option<Arc<dyn SerializerRegistry>>§file_formats: Option<Vec<Arc<dyn FileFormatFactory>>>§config: Option<SessionConfig>§table_options: Option<TableOptions>§execution_props: Option<ExecutionProps>§table_factories: Option<HashMap<String, Arc<dyn TableProviderFactory>>>§runtime_env: Option<Arc<RuntimeEnv>>§function_factory: Option<Arc<dyn FunctionFactory>>§analyzer_rules: Option<Vec<Arc<dyn AnalyzerRule + Send + Sync>>>§optimizer_rules: Option<Vec<Arc<dyn OptimizerRule + Send + Sync>>>§physical_optimizer_rules: Option<Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>>Implementations§
Source§impl SessionStateBuilder
impl SessionStateBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new empty SessionStateBuilder.
See Self::with_default_features to install the default set of functions,
catalogs, etc.
To create a SessionStateBuilder with default features such as functions,
please see Self::new_with_default_features.
Sourcepub fn new_from_existing(existing: SessionState) -> Self
pub fn new_from_existing(existing: SessionState) -> Self
Returns a new SessionStateBuilder based on an existing SessionState.
The session id for the new builder will be unset; all other fields will
be cloned from existing. If the default
catalog exists in existing session state, the new session state will not
create default catalog and schema.
Sourcepub fn with_default_features(self) -> Self
pub fn with_default_features(self) -> Self
Adds defaults for table_factories, file formats, expr_planners and builtin scalar, aggregate and windows functions.
Note overwrites any previously registered items with the same name.
Sourcepub fn new_with_default_features() -> Self
pub fn new_with_default_features() -> Self
Returns a new SessionStateBuilder with default features.
This is equivalent to calling Self::new() followed by Self::with_default_features().
use datafusion::execution::session_state::SessionStateBuilder;
// Create a new SessionState with default features
let session_state = SessionStateBuilder::new_with_default_features()
.with_session_id("my_session".to_string())
.build();Sourcepub fn with_session_id(self, session_id: String) -> Self
pub fn with_session_id(self, session_id: String) -> Self
Set the session id.
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
Set the AnalyzerRules optimizer plan rules.
Sourcepub fn with_analyzer_rule(
self,
analyzer_rule: Arc<dyn AnalyzerRule + Send + Sync>,
) -> Self
pub fn with_analyzer_rule( self, analyzer_rule: Arc<dyn AnalyzerRule + Send + Sync>, ) -> Self
Add analyzer_rule to the end of the list of
AnalyzerRules used to rewrite queries.
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
Set the OptimizerRules used to optimize plans.
Sourcepub fn with_optimizer_rule(
self,
optimizer_rule: Arc<dyn OptimizerRule + Send + Sync>,
) -> Self
pub fn with_optimizer_rule( self, optimizer_rule: Arc<dyn OptimizerRule + Send + Sync>, ) -> Self
Add optimizer_rule to the end of the list of
OptimizerRules used to rewrite queries.
Sourcepub fn with_expr_planners(
self,
expr_planners: Vec<Arc<dyn ExprPlanner>>,
) -> Self
pub fn with_expr_planners( self, expr_planners: Vec<Arc<dyn ExprPlanner>>, ) -> Self
Set the ExprPlanners used to customize the behavior of the SQL planner.
Sourcepub fn with_type_planner(self, type_planner: Arc<dyn TypePlanner>) -> Self
pub fn with_type_planner(self, type_planner: Arc<dyn TypePlanner>) -> Self
Set the TypePlanner used to customize the behavior of the SQL planner.
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
Set the PhysicalOptimizerRules used to optimize plans.
Sourcepub fn with_physical_optimizer_rule(
self,
physical_optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync>,
) -> Self
pub fn with_physical_optimizer_rule( self, physical_optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync>, ) -> Self
Add physical_optimizer_rule to the end of the list of
PhysicalOptimizerRules used to rewrite queries.
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
Set the QueryPlanner
Sourcepub fn with_catalog_list(
self,
catalog_list: Arc<dyn CatalogProviderList>,
) -> Self
pub fn with_catalog_list( self, catalog_list: Arc<dyn CatalogProviderList>, ) -> Self
Set the CatalogProviderList
Sourcepub fn with_table_functions(
self,
table_functions: HashMap<String, Arc<TableFunction>>,
) -> Self
pub fn with_table_functions( self, table_functions: HashMap<String, Arc<TableFunction>>, ) -> Self
Set the map of TableFunctions
Sourcepub fn with_table_function_list(
self,
table_functions: Vec<Arc<TableFunction>>,
) -> Self
pub fn with_table_function_list( self, table_functions: Vec<Arc<TableFunction>>, ) -> Self
Set the list of TableFunctions
Sourcepub fn with_scalar_functions(
self,
scalar_functions: Vec<Arc<ScalarUDF>>,
) -> Self
pub fn with_scalar_functions( self, scalar_functions: Vec<Arc<ScalarUDF>>, ) -> Self
Set the map of ScalarUDFs
Sourcepub fn with_aggregate_functions(
self,
aggregate_functions: Vec<Arc<AggregateUDF>>,
) -> Self
pub fn with_aggregate_functions( self, aggregate_functions: Vec<Arc<AggregateUDF>>, ) -> Self
Set the map of AggregateUDFs
Sourcepub fn with_window_functions(
self,
window_functions: Vec<Arc<WindowUDF>>,
) -> Self
pub fn with_window_functions( self, window_functions: Vec<Arc<WindowUDF>>, ) -> Self
Set the map of WindowUDFs
Sourcepub fn with_serializer_registry(
self,
serializer_registry: Arc<dyn SerializerRegistry>,
) -> Self
pub fn with_serializer_registry( self, serializer_registry: Arc<dyn SerializerRegistry>, ) -> Self
Set the SerializerRegistry
Sourcepub fn with_file_formats(
self,
file_formats: Vec<Arc<dyn FileFormatFactory>>,
) -> Self
pub fn with_file_formats( self, file_formats: Vec<Arc<dyn FileFormatFactory>>, ) -> Self
Set the map of FileFormatFactorys
Sourcepub fn with_config(self, config: SessionConfig) -> Self
pub fn with_config(self, config: SessionConfig) -> Self
Set the SessionConfig
Sourcepub fn with_table_options(self, table_options: TableOptions) -> Self
pub fn with_table_options(self, table_options: TableOptions) -> Self
Set the TableOptions
Sourcepub fn with_execution_props(self, execution_props: ExecutionProps) -> Self
pub fn with_execution_props(self, execution_props: ExecutionProps) -> Self
Set the ExecutionProps
Sourcepub fn with_table_factory(
self,
key: String,
table_factory: Arc<dyn TableProviderFactory>,
) -> Self
pub fn with_table_factory( self, key: String, table_factory: Arc<dyn TableProviderFactory>, ) -> Self
Add a TableProviderFactory to the map of factories
Sourcepub fn with_table_factories(
self,
table_factories: HashMap<String, Arc<dyn TableProviderFactory>>,
) -> Self
pub fn with_table_factories( self, table_factories: HashMap<String, Arc<dyn TableProviderFactory>>, ) -> Self
Set the map of TableProviderFactorys
Sourcepub fn with_runtime_env(self, runtime_env: Arc<RuntimeEnv>) -> Self
pub fn with_runtime_env(self, runtime_env: Arc<RuntimeEnv>) -> Self
Set the RuntimeEnv
Sourcepub fn with_function_factory(
self,
function_factory: Option<Arc<dyn FunctionFactory>>,
) -> Self
pub fn with_function_factory( self, function_factory: Option<Arc<dyn FunctionFactory>>, ) -> Self
Set a FunctionFactory to handle CREATE FUNCTION statements
Sourcepub fn with_object_store(
self,
url: &Url,
object_store: Arc<dyn ObjectStore>,
) -> Self
pub fn with_object_store( self, url: &Url, object_store: Arc<dyn ObjectStore>, ) -> Self
Register an ObjectStore to the RuntimeEnv. See RuntimeEnv::register_object_store
for more details.
Note that this creates a default RuntimeEnv if there isn’t one passed in already.
let url = Url::try_from("file://").unwrap();
let object_store = object_store::local::LocalFileSystem::new();
let state = SessionStateBuilder::new()
.with_config(SessionConfig::new())
.with_object_store(&url, Arc::new(object_store))
.with_default_features()
.build();Sourcepub fn build(self) -> SessionState
pub fn build(self) -> SessionState
Builds a SessionState with the current configuration.
Note that there is an explicit option for enabling catalog and schema defaults in SessionConfig::create_default_catalog_and_schema which if enabled will be built here.
Sourcepub fn session_id(&self) -> &Option<String>
pub fn session_id(&self) -> &Option<String>
Returns the current session_id value
Sourcepub fn expr_planners(&mut self) -> &mut Option<Vec<Arc<dyn ExprPlanner>>>
pub fn expr_planners(&mut self) -> &mut Option<Vec<Arc<dyn ExprPlanner>>>
Returns the current expr_planners value
Sourcepub fn type_planner(&mut self) -> &mut Option<Arc<dyn TypePlanner>>
pub fn type_planner(&mut self) -> &mut Option<Arc<dyn TypePlanner>>
Returns the current type_planner value
Sourcepub fn physical_optimizers(&mut self) -> &mut Option<PhysicalOptimizer>
pub fn physical_optimizers(&mut self) -> &mut Option<PhysicalOptimizer>
Returns the current physical_optimizers value
Sourcepub fn query_planner(
&mut self,
) -> &mut Option<Arc<dyn QueryPlanner + Send + Sync>>
pub fn query_planner( &mut self, ) -> &mut Option<Arc<dyn QueryPlanner + Send + Sync>>
Returns the current query_planner value
Sourcepub fn catalog_list(&mut self) -> &mut Option<Arc<dyn CatalogProviderList>>
pub fn catalog_list(&mut self) -> &mut Option<Arc<dyn CatalogProviderList>>
Returns the current catalog_list value
Sourcepub fn table_functions(
&mut self,
) -> &mut Option<HashMap<String, Arc<TableFunction>>>
pub fn table_functions( &mut self, ) -> &mut Option<HashMap<String, Arc<TableFunction>>>
Returns the current table_functions value
Sourcepub fn scalar_functions(&mut self) -> &mut Option<Vec<Arc<ScalarUDF>>>
pub fn scalar_functions(&mut self) -> &mut Option<Vec<Arc<ScalarUDF>>>
Returns the current scalar_functions value
Sourcepub fn aggregate_functions(&mut self) -> &mut Option<Vec<Arc<AggregateUDF>>>
pub fn aggregate_functions(&mut self) -> &mut Option<Vec<Arc<AggregateUDF>>>
Returns the current aggregate_functions value
Sourcepub fn window_functions(&mut self) -> &mut Option<Vec<Arc<WindowUDF>>>
pub fn window_functions(&mut self) -> &mut Option<Vec<Arc<WindowUDF>>>
Returns the current window_functions value
Sourcepub fn serializer_registry(
&mut self,
) -> &mut Option<Arc<dyn SerializerRegistry>>
pub fn serializer_registry( &mut self, ) -> &mut Option<Arc<dyn SerializerRegistry>>
Returns the current serializer_registry value
Sourcepub fn file_formats(&mut self) -> &mut Option<Vec<Arc<dyn FileFormatFactory>>>
pub fn file_formats(&mut self) -> &mut Option<Vec<Arc<dyn FileFormatFactory>>>
Returns the current file_formats value
Sourcepub fn config(&mut self) -> &mut Option<SessionConfig>
pub fn config(&mut self) -> &mut Option<SessionConfig>
Returns the current session_config value
Sourcepub fn table_options(&mut self) -> &mut Option<TableOptions>
pub fn table_options(&mut self) -> &mut Option<TableOptions>
Returns the current table_options value
Sourcepub fn execution_props(&mut self) -> &mut Option<ExecutionProps>
pub fn execution_props(&mut self) -> &mut Option<ExecutionProps>
Returns the current execution_props value
Sourcepub fn table_factories(
&mut self,
) -> &mut Option<HashMap<String, Arc<dyn TableProviderFactory>>>
pub fn table_factories( &mut self, ) -> &mut Option<HashMap<String, Arc<dyn TableProviderFactory>>>
Returns the current table_factories value
Sourcepub fn runtime_env(&mut self) -> &mut Option<Arc<RuntimeEnv>>
pub fn runtime_env(&mut self) -> &mut Option<Arc<RuntimeEnv>>
Returns the current runtime_env value
Sourcepub fn function_factory(&mut self) -> &mut Option<Arc<dyn FunctionFactory>>
pub fn function_factory(&mut self) -> &mut Option<Arc<dyn FunctionFactory>>
Returns the current function_factory value
Sourcepub fn analyzer_rules(
&mut self,
) -> &mut Option<Vec<Arc<dyn AnalyzerRule + Send + Sync>>>
pub fn analyzer_rules( &mut self, ) -> &mut Option<Vec<Arc<dyn AnalyzerRule + Send + Sync>>>
Returns the current analyzer_rules value
Sourcepub fn optimizer_rules(
&mut self,
) -> &mut Option<Vec<Arc<dyn OptimizerRule + Send + Sync>>>
pub fn optimizer_rules( &mut self, ) -> &mut Option<Vec<Arc<dyn OptimizerRule + Send + Sync>>>
Returns the current optimizer_rules value
Sourcepub fn physical_optimizer_rules(
&mut self,
) -> &mut Option<Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>>
pub fn physical_optimizer_rules( &mut self, ) -> &mut Option<Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>>
Returns the current physical_optimizer_rules value
Trait Implementations§
Source§impl Debug for SessionStateBuilder
impl Debug for SessionStateBuilder
Source§impl Default for SessionStateBuilder
impl Default for SessionStateBuilder
Source§impl From<SessionContext> for SessionStateBuilder
impl From<SessionContext> for SessionStateBuilder
Source§fn from(session: SessionContext) -> Self
fn from(session: SessionContext) -> Self
Source§impl From<SessionState> for SessionStateBuilder
impl From<SessionState> for SessionStateBuilder
Source§fn from(state: SessionState) -> Self
fn from(state: SessionState) -> Self
Auto Trait Implementations§
impl Freeze for SessionStateBuilder
impl !RefUnwindSafe for SessionStateBuilder
impl Send for SessionStateBuilder
impl Sync for SessionStateBuilder
impl Unpin for SessionStateBuilder
impl !UnwindSafe for SessionStateBuilder
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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