@since(2.0)
def getOrCreate(self):
    'Gets an existing :class:`SparkSession` or, if there is no existing one, creates a\n            new one based on the options set in this builder.\n\n            This method first checks whether there is a valid global default SparkSession, and if\n            yes, return that one. If no valid global default SparkSession exists, the method\n            creates a new SparkSession and assigns the newly created SparkSession as the global\n            default.\n\n            >>> s1 = SparkSession.builder.config("k1", "v1").getOrCreate()\n            >>> s1.conf.get("k1") == s1.sparkContext.getConf().get("k1") == "v1"\n            True\n\n            In case an existing SparkSession is returned, the config options specified\n            in this builder will be applied to the existing SparkSession.\n\n            >>> s2 = SparkSession.builder.config("k2", "v2").getOrCreate()\n            >>> s1.conf.get("k1") == s2.conf.get("k1")\n            True\n            >>> s1.conf.get("k2") == s2.conf.get("k2")\n            True\n            '
    with self._lock:
        from pyspark.context import SparkContext
        from pyspark.conf import SparkConf
        session = SparkSession._instantiatedSession
        if ((session is None) or (session._sc._jsc is None)):
            sparkConf = SparkConf()
            for (key, value) in self._options.items():
                sparkConf.set(key, value)
            sc = SparkContext.getOrCreate(sparkConf)
            for (key, value) in self._options.items():
                sc._conf.set(key, value)
            session = SparkSession(sc)
        for (key, value) in self._options.items():
            session.conf.set(key, value)
        for (key, value) in self._options.items():
            session.sparkContext._conf.set(key, value)
        return session
Gets an existing :class:`SparkSession` or, if there is no existing one, creates a
new one based on the options set in this builder.

This method first checks whether there is a valid global default SparkSession, and if
yes, return that one. If no valid global default SparkSession exists, the method
creates a new SparkSession and assigns the newly created SparkSession as the global
default.

>>> 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, the config options specified
in this builder will be applied to the existing SparkSession.

>>> s2 = SparkSession.builder.config("k2", "v2").getOrCreate()
>>> s1.conf.get("k1") == s2.conf.get("k1")
True
>>> s1.conf.get("k2") == s2.conf.get("k2")
True
@since(2.0)
def getOrCreate(self):
    'Gets an existing :class:`SparkSession` or, if there is no existing one, creates a\n            new one based on the options set in this builder.\n\n            This method first checks whether there is a valid global default SparkSession, and if\n            yes, return that one. If no valid global default SparkSession exists, the method\n            creates a new SparkSession and assigns the newly created SparkSession as the global\n            default.\n\n            >>> s1 = SparkSession.builder.config("k1", "v1").getOrCreate()\n            >>> s1.conf.get("k1") == s1.sparkContext.getConf().get("k1") == "v1"\n            True\n\n            In case an existing SparkSession is returned, the config options specified\n            in this builder will be applied to the existing SparkSession.\n\n            >>> s2 = SparkSession.builder.config("k2", "v2").getOrCreate()\n            >>> s1.conf.get("k1") == s2.conf.get("k1")\n            True\n            >>> s1.conf.get("k2") == s2.conf.get("k2")\n            True\n            '
    with self._lock:
        from pyspark.context import SparkContext
        from pyspark.conf import SparkConf
        session = SparkSession._instantiatedSession
        if ((session is None) or (session._sc._jsc is None)):
            sparkConf = SparkConf()
            for (key, value) in self._options.items():
                sparkConf.set(key, value)
            sc = SparkContext.getOrCreate(sparkConf)
            for (key, value) in self._options.items():
                sc._conf.set(key, value)
            session = SparkSession(sc)
        for (key, value) in self._options.items():
            session.conf.set(key, value)
        for (key, value) in self._options.items():
            session.sparkContext._conf.set(key, value)
        return session