builder.config(key: Optional[str] = None, value: Optional[Any] = None, conf: Optional[pyspark.conf.SparkConf] = None, *, map: Optional[Dict[str, OptionalPrimitiveType]] = None) → SparkSession.Builder

Sets a config option. Options set using this method are automatically propagated to both SparkConf and SparkSession’s own configuration.

New in version 2.0.0.

Changed in version 3.4.0: Supports Spark Connect.

keystr, optional

a key name string for configuration property

valuestr, optional

a value for configuration property

confSparkConf, optional

an instance of SparkConf

map: dictionary, optional

a dictionary of configurations to set

New in version 3.4.0.



For an existing class:SparkConf, use conf parameter.

>>> from pyspark.conf import SparkConf
>>> SparkSession.builder.config(conf=SparkConf())

For a (key, value) pair, you can omit parameter names.

>>> SparkSession.builder.config("spark.some.config.option", "some-value")

Additionally, you can pass a dictionary of configurations to set.

>>> SparkSession.builder.config(
...     map={"spark.some.config.number": 123, "spark.some.config.float": 0.123})