code: def getActiveSession(cls):
          
          from pyspark import SparkContext
          sc = SparkContext._active_spark_context
          if sc is None:
              return None
          else:
              if sc._jvm.SparkSession.getActiveSession().isDefined():
                  SparkSession(sc, sc._jvm.SparkSession.getActiveSession().get())
                  return SparkSession._activeSession
              else:
                  return None
docs: Returns the active SparkSession for the current thread, returned by the builder.
          >>> s = SparkSession.getActiveSession()
          >>> l = [('Alice', 1)]
          >>> rdd = s.sparkContext.parallelize(l)
          >>> df = s.createDataFrame(rdd, ['name', 'age'])
          >>> df.select("age").collect()
          [Row(age=1)]