Skip to content

Connect

koheesio.spark.utils.connect.is_remote_session #

is_remote_session(
    spark: Optional[SparkSession] = None,
) -> bool
Source code in src/koheesio/spark/utils/connect.py
def is_remote_session(spark: Optional[SparkSession] = None) -> bool:
    result = False

    if (_spark := spark or get_active_session()) and check_if_pyspark_connect_is_supported():
        # result = True if _spark.conf.get("spark.remote", None) else False  # type: ignore
        from pyspark.sql.connect.session import SparkSession as ConnectSparkSession

        result = isinstance(_spark, ConnectSparkSession)

    return result