Package org.apache.spark.sql
Class SparkSession.Builder
Object
org.apache.spark.sql.SparkSession.Builder
- Enclosing class:
 - SparkSession
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic Stringstatic Stringstatic StringSets a name for the application, which will be shown in the Spark web UI.static Stringclassic()Make the builder create a Classic SparkSession.Sets a config option.Sets a config option.Sets a config option.Sets a config option.Sets a config option.Sets a list of config options based on the givenSparkConf.Sets a config option.connect()Make the builder create a Connect SparkSession.static Stringcreate()Create a newSparkSession.Enables Hive support, including connectivity to a persistent Hive metastore, support for Hive serdes, and Hive user-defined functions.Gets an existingSparkSessionor, if there is no existing one, creates a new one based on the options set in this builder.Sets the Spark master URL to connect to, such as "local" to run locally, "local[4]" to run locally with 4 cores, or "spark://master:7077" to run on a Spark standalone cluster.static StringSets the Spark Connect remote URL.withExtensions(scala.Function1<SparkSessionExtensions, scala.runtime.BoxedUnit> f) Inject extensions into theSparkSession. 
- 
Constructor Details
- 
Builder
public Builder() 
 - 
 - 
Method Details
- 
appName
Sets a name for the application, which will be shown in the Spark web UI. If no application name is set, a randomly generated name will be used.- Parameters:
 name- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
classic
Make the builder create a Classic SparkSession.- Returns:
 - (undocumented)
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 key- (undocumented)value- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 key- (undocumented)value- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 key- (undocumented)value- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 key- (undocumented)value- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 map- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a config option. Options set using this method are automatically propagated to bothSparkConfand SparkSession's own configuration.- Parameters:
 map- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
config
Sets a list of config options based on the givenSparkConf.- Parameters:
 conf- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
connect
Make the builder create a Connect SparkSession.- Returns:
 - (undocumented)
 
 - 
create
Create a newSparkSession.This will always return a newly created session.
This method will update the default and/or active session if they are not set.
- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
enableHiveSupport
Enables Hive support, including connectivity to a persistent Hive metastore, support for Hive serdes, and Hive user-defined functions.- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
getOrCreate
Gets an existingSparkSessionor, if there is no existing one, creates a new one based on the options set in this builder.This method first checks whether there is a valid thread-local SparkSession, and if yes, return that one. It then checks whether there is a valid global default SparkSession, and if yes, return that one. If no valid global default SparkSession exists, the method creates a new SparkSession and assigns the newly created SparkSession as the global default.
In case an existing SparkSession is returned, the non-static config options specified in this builder will be applied to the existing SparkSession.
- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
master
Sets the Spark master URL to connect to, such as "local" to run locally, "local[4]" to run locally with 4 cores, or "spark://master:7077" to run on a Spark standalone cluster.- Parameters:
 master- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
remote
Sets the Spark Connect remote URL.- Parameters:
 connectionString- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
withExtensions
public SparkSession.Builder withExtensions(scala.Function1<SparkSessionExtensions, scala.runtime.BoxedUnit> f) Inject extensions into theSparkSession. This allows a user to add Analyzer rules, Optimizer rules, Planning Strategies or a customized parser.- Parameters:
 f- (undocumented)- Returns:
 - (undocumented)
 - Inheritdoc:
 
 - 
MASTER_KEY
 - 
APP_NAME_KEY
 - 
CATALOG_IMPL_KEY
 - 
CONNECT_REMOTE_KEY
 - 
API_MODE_KEY
 - 
API_MODE_CLASSIC
 - 
API_MODE_CONNECT
 
 -