Answers for "Gets an existing SparkSession or, if there is no existing one, creates a new one based on the options set in this builder"

0

Gets an existing SparkSession or, if there is no existing one, creates a new one based on the options set in this builder

# 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
Posted by: Guest on April-10-2020

Code answers related to "Gets an existing SparkSession or, if there is no existing one, creates a new one based on the options set in this builder"

Python Answers by Framework

Browse Popular Code Answers by Language