BaseSessionStateBuilder — Generic Builder of SessionState¶
BaseSessionStateBuilder is an abstraction of builders that can produce a new BaseSessionStateBuilder to create a SessionState.
spark.sql.catalogImplementation Configuration Property
BaseSessionStateBuilder and spark.sql.catalogImplementation configuration property allow for Hive and non-Hive Spark deployments.
BaseSessionStateBuilder holds properties that (together with newBuilder) are used to create a SessionState.
Contract¶
newBuilder¶
Produces a new BaseSessionStateBuilder for given SparkSession.md[SparkSession] and optional SessionState.md[SessionState]
Used when BaseSessionStateBuilder is requested to <
Implementations¶
Creating Instance¶
BaseSessionStateBuilder takes the following to be created:
- SparkSession
- Optional parent SessionState (default: undefined)
BaseSessionStateBuilder is created when SparkSession is requested to instantiateSessionState.
Session-Specific Registries¶
The following registries are Scala lazy values which are created once and on demand (when accessed for the first time).
Analyzer¶
SessionCatalog¶
Note
HiveSessionStateBuilder manages its own Hive-aware HiveSessionCatalog.
CatalogManager¶
CatalogManager that is created with this V2SessionCatalog and this SessionCatalog.
catalogManager is used when:
BaseSessionStateBuilderis requested for the Analyzer and the OptimizerHiveSessionStateBuilderis requested for the Analyzer
SQLConf¶
ExperimentalMethods¶
FunctionRegistry¶
SessionResourceLoader¶
SessionResourceLoader
ParserInterface¶
TableFunctionRegistry¶
When requested for the first time (as a lazy val), tableFunctionRegistry requests the parent SessionState (if available) to clone the tableFunctionRegistry or requests the SparkSessionExtensions to register the built-in function expressions.
tableFunctionRegistry is used when:
HiveSessionStateBuilderis requested for a HiveSessionCatalogBaseSessionStateBuilderis requested for a SessionCatalog and a SessionState
V2SessionCatalog¶
V2SessionCatalog that is created with this SessionCatalog.
This V2SessionCatalog is used when:
BaseSessionStateBuilderis requested for the CatalogManager
Custom Operator Optimization Rules¶
Custom operator optimization rules to add to the base Operator Optimization batch.
When requested for the custom rules, customOperatorOptimizationRules simply requests the SparkSessionExtensions to buildOptimizerRules.
customOperatorOptimizationRules is used when BaseSessionStateBuilder is requested for an Optimizer.
SparkSessionExtensions¶
ExecutionListenerManager¶
Optimizer¶
optimizer creates a SparkOptimizer for the CatalogManager, SessionCatalog and ExperimentalMethods.
The SparkOptimizer uses the following extension methods:
- customEarlyScanPushDownRules for earlyScanPushDownRules
- customOperatorOptimizationRules for extendedOperatorOptimizationRules
optimizer is used when BaseSessionStateBuilder is requested to build a SessionState (as the optimizerBuilder function to build a logical query plan optimizer on demand).
SparkPlanner¶
StreamingQueryManager¶
Spark Structured Streaming's StreamingQueryManager
UDFRegistration¶
Creating Clone of SessionState¶
createClone creates a SessionState using newBuilder followed by build.
createClone is used when BaseSessionStateBuilder is requested for a SessionState.
Building SessionState¶
build creates a SessionState with the following:
- SparkSession.md#sharedState[SharedState] of the <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
> - <
>
build is used when:
-
SparkSessionis requested for a SessionState (that in turn builds one using a class name based on spark.sql.catalogImplementation configuration property) -
BaseSessionStateBuilderis requested to create a clone of aSessionState
Getting Function to Create QueryExecution For LogicalPlan¶
createQueryExecution simply returns a function that takes a LogicalPlan and creates a QueryExecution with the SparkSession and the logical plan.
createQueryExecution is used when BaseSessionStateBuilder is requested to create a SessionState instance.
ColumnarRules¶
columnarRules requests the SparkSessionExtensions to buildColumnarRules.
columnarRules is used when:
BaseSessionStateBuilderis requested to build a SessionState instance
customCheckRules¶
customCheckRules requests the SparkSessionExtensions to buildCheckRules on the SparkSession.
customCheckRules is used when:
BaseSessionStateBuilderis requested for an AnalyzerHiveSessionStateBuilderis requested for an Analyzer
Adaptive Rules¶
adaptiveRulesHolder creates a new AdaptiveRulesHolder with the user-defined AQE rules built using the SparkSessionExtensions: