pyspark.sql.SparkSession.getActiveSession

classmethod SparkSession.getActiveSession()[source]

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)]

New in version 3.0.