Skip to main content

getActiveSession

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

Syntax

SparkSession.getActiveSession()

Returns

SparkSession or None

Examples

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