config(SparkSession.Builder)

設定一個設定選項。 使用此方法設定的選項會自動傳播到 SparkConf 和 SparkSession的自身設定中。

Syntax

config(key=None, value=None, conf=None, *, map=None)

Parameters

參數 類型 說明
key 力量,選用 一個用於設定屬性的鍵名字串。
value 力量,選用 一個配置屬性的值。
conf SparkConf,選用 SparkConf的實例。
map DICT,選擇性 一個設定字典。

Returns

SparkSession.Builder

Examples

# For an existing SparkConf, use the conf parameter.
from pyspark.conf import SparkConf
conf = SparkConf().setAppName("example").setMaster("local")
SparkSession.builder.config(conf=conf)

# For a (key, value) pair, you can omit the parameter names.
SparkSession.builder.config("spark.some.config.option", "some-value")

# Set multiple configurations.
SparkSession.builder.config(
    "spark.some.config.number", 123).config("spark.some.config.float", 0.123)

# Set multiple configurations using a dictionary.
SparkSession.builder.config(
    map={"spark.some.config.number": 123, "spark.some.config.float": 0.123})