nxcals.api.extraction.data.builders.SparkSession.getActiveSession

classmethod SparkSession.getActiveSession() Optional[SparkSession]

Returns the active SparkSession for the current thread, returned by the builder

New in version 3.0.0.

Changed in version 3.5.0: Supports Spark Connect.

Returns:

Spark session if an active session exists for the current thread

Return type:

SparkSession

Examples

>>> s = SparkSession.getActiveSession()
>>> df = s.createDataFrame([('Alice', 1)], ['name', 'age'])
>>> df.select("age").show()
+---+
|age|
+---+
|  1|
+---+