pyspark.sql.SparkSession.builder.config

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.

Parameters
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.

Returns
SparkSession.Builder

Examples

For an existing class:SparkConf, use conf parameter.

>>> from pyspark.conf import SparkConf
>>> SparkSession.builder.config(conf=SparkConf())
<pyspark.sql.session.SparkSession.Builder...

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

>>> SparkSession.builder.config("spark.some.config.option", "some-value")
<pyspark.sql.session.SparkSession.Builder...

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})
<pyspark.sql.session.SparkSession.Builder...