SessionStateBuilder

Struct SessionStateBuilder 

Source
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

Source

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.

Source

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.

Source

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.

Source

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();
Source

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

Set the session id.

Source

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

Set the AnalyzerRules optimizer plan rules.

Source

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.

Source

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

Set the OptimizerRules used to optimize plans.

Source

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.

Source

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.

Source

pub fn with_type_planner(self, type_planner: Arc<dyn TypePlanner>) -> Self

Set the TypePlanner used to customize the behavior of the SQL planner.

Source

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

Set the PhysicalOptimizerRules used to optimize plans.

Source

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.

Source

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

Set the QueryPlanner

Source

pub fn with_catalog_list( self, catalog_list: Arc<dyn CatalogProviderList>, ) -> Self

Source

pub fn with_table_functions( self, table_functions: HashMap<String, Arc<TableFunction>>, ) -> Self

Set the map of TableFunctions

Source

pub fn with_table_function_list( self, table_functions: Vec<Arc<TableFunction>>, ) -> Self

Set the list of TableFunctions

Source

pub fn with_scalar_functions( self, scalar_functions: Vec<Arc<ScalarUDF>>, ) -> Self

Set the map of ScalarUDFs

Source

pub fn with_aggregate_functions( self, aggregate_functions: Vec<Arc<AggregateUDF>>, ) -> Self

Set the map of AggregateUDFs

Source

pub fn with_window_functions( self, window_functions: Vec<Arc<WindowUDF>>, ) -> Self

Set the map of WindowUDFs

Source

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

Source

pub fn with_file_formats( self, file_formats: Vec<Arc<dyn FileFormatFactory>>, ) -> Self

Set the map of FileFormatFactorys

Source

pub fn with_config(self, config: SessionConfig) -> Self

Set the SessionConfig

Source

pub fn with_table_options(self, table_options: TableOptions) -> Self

Set the TableOptions

Source

pub fn with_execution_props(self, execution_props: ExecutionProps) -> Self

Source

pub fn with_table_factory( self, key: String, table_factory: Arc<dyn TableProviderFactory>, ) -> Self

Add a TableProviderFactory to the map of factories

Source

pub fn with_table_factories( self, table_factories: HashMap<String, Arc<dyn TableProviderFactory>>, ) -> Self

Set the map of TableProviderFactorys

Source

pub fn with_runtime_env(self, runtime_env: Arc<RuntimeEnv>) -> Self

Set the RuntimeEnv

Source

pub fn with_function_factory( self, function_factory: Option<Arc<dyn FunctionFactory>>, ) -> Self

Set a FunctionFactory to handle CREATE FUNCTION statements

Source

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();
Source

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.

Source

pub fn session_id(&self) -> &Option<String>

Returns the current session_id value

Source

pub fn analyzer(&mut self) -> &mut Option<Analyzer>

Returns the current analyzer value

Source

pub fn expr_planners(&mut self) -> &mut Option<Vec<Arc<dyn ExprPlanner>>>

Returns the current expr_planners value

Source

pub fn type_planner(&mut self) -> &mut Option<Arc<dyn TypePlanner>>

Returns the current type_planner value

Source

pub fn optimizer(&mut self) -> &mut Option<Optimizer>

Returns the current optimizer value

Source

pub fn physical_optimizers(&mut self) -> &mut Option<PhysicalOptimizer>

Returns the current physical_optimizers value

Source

pub fn query_planner( &mut self, ) -> &mut Option<Arc<dyn QueryPlanner + Send + Sync>>

Returns the current query_planner value

Source

pub fn catalog_list(&mut self) -> &mut Option<Arc<dyn CatalogProviderList>>

Returns the current catalog_list value

Source

pub fn table_functions( &mut self, ) -> &mut Option<HashMap<String, Arc<TableFunction>>>

Returns the current table_functions value

Source

pub fn scalar_functions(&mut self) -> &mut Option<Vec<Arc<ScalarUDF>>>

Returns the current scalar_functions value

Source

pub fn aggregate_functions(&mut self) -> &mut Option<Vec<Arc<AggregateUDF>>>

Returns the current aggregate_functions value

Source

pub fn window_functions(&mut self) -> &mut Option<Vec<Arc<WindowUDF>>>

Returns the current window_functions value

Source

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

Returns the current serializer_registry value

Source

pub fn file_formats(&mut self) -> &mut Option<Vec<Arc<dyn FileFormatFactory>>>

Returns the current file_formats value

Source

pub fn config(&mut self) -> &mut Option<SessionConfig>

Returns the current session_config value

Source

pub fn table_options(&mut self) -> &mut Option<TableOptions>

Returns the current table_options value

Source

pub fn execution_props(&mut self) -> &mut Option<ExecutionProps>

Returns the current execution_props value

Source

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

Returns the current table_factories value

Source

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

Returns the current runtime_env value

Source

pub fn function_factory(&mut self) -> &mut Option<Arc<dyn FunctionFactory>>

Returns the current function_factory value

Source

pub fn analyzer_rules( &mut self, ) -> &mut Option<Vec<Arc<dyn AnalyzerRule + Send + Sync>>>

Returns the current analyzer_rules value

Source

pub fn optimizer_rules( &mut self, ) -> &mut Option<Vec<Arc<dyn OptimizerRule + Send + Sync>>>

Returns the current optimizer_rules value

Source

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

Source§

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

Prefer having short fields at the top and long vector fields near the end Group fields by

Source§

impl Default for SessionStateBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<SessionContext> for SessionStateBuilder

Source§

fn from(session: SessionContext) -> Self

Converts to this type from the input type.
Source§

impl From<SessionState> for SessionStateBuilder

Source§

fn from(state: SessionState) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,