📌  相关文章
📜  获取现有的 SparkSession,或者,如果不存在,则根据此构建器中设置的选项创建一个新的 SparkSession - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:56.014000             🧑  作者: Mango

代码示例1
# if there is no existing SparkSession, creates a new one

s1 = SparkSession.builder.config("k1", "v1").getOrCreate()
s1.conf.get("k1") == s1.sparkContext.getConf().get("k1") == "v1"
# True

# In case an existing SparkSession is returned

s2 = SaprkSession.builder.config("k2", "v2").getOrCreate()
s1.conf.get("k1") == s2.conf.get("k1")
# True
s1.conf.get("k2") == s2.conf.get("k2")
# True