sparkR.session {SparkR}R Documentation

Get the existing SparkSession or initialize a new SparkSession.


SparkSession is the entry point into SparkR. sparkR.session gets the existing SparkSession or initializes a new SparkSession. Additional Spark properties can be set in ..., and these named parameters take priority over values in master, appName, named lists of sparkConfig.


sparkR.session(master = "", appName = "SparkR",
  sparkHome = Sys.getenv("SPARK_HOME"), sparkConfig = list(),
  sparkJars = "", sparkPackages = "", enableHiveSupport = TRUE, ...)



the Spark master URL.


application name to register with cluster manager.


Spark Home directory.


named list of Spark configuration to set on worker nodes.


character vector of jar files to pass to the worker nodes.


character vector of package coordinates


enable support for Hive, fallback if not built with Hive support; once set, this cannot be turned off on an existing session


named Spark properties passed to the method.


When called in an interactive session, this method checks for the Spark installation, and, if not found, it will be downloaded and cached automatically. Alternatively, install.spark can be called manually.

A default warehouse is created automatically in the current directory when a managed table is created via sql statement CREATE TABLE, for example. To change the location of the warehouse, set the named parameter spark.sql.warehouse.dir to the SparkSession. Along with the warehouse, an accompanied metastore may also be automatically created in the current directory when a new SparkSession is initialized with enableHiveSupport set to TRUE, which is the default. For more details, refer to Hive configuration at

For details on how to initialize and use SparkR, refer to SparkR programming guide at


sparkR.session since 2.0.0


## Not run: 
##D sparkR.session()
##D df <- read.json(path)
##D sparkR.session("local[2]", "SparkR", "/home/spark")
##D sparkR.session("yarn-client", "SparkR", "/home/spark",
##D                list(spark.executor.memory="4g"),
##D                c("one.jar", "two.jar", "three.jar"),
##D                c("com.databricks:spark-avro_2.10:2.0.1"))
##D sparkR.session(spark.master = "yarn-client", spark.executor.memory = "4g")
## End(Not run)

[Package SparkR version 2.2.0 Index]